diff --git a/lua/core/keys.lua b/lua/core/keys.lua index b312698..c4d8513 100644 --- a/lua/core/keys.lua +++ b/lua/core/keys.lua @@ -14,32 +14,70 @@ vim.g.maplocalleader = ' ' -- normal_mode = "n", insert_mode = "i", visual_mode = "v", -- visual_block_mode = "x", term_mode = "t", command_mode = "c", --- Comment --- map({ 'n', 'v' }, ';', 'gcc', { desc = 'Comment toggle', remap = true }) --- map({ 'v', 'x' }, ';', 'gc', { desc = 'Comment toggle', remap = true }) - --- Able to use semicolon in normal mode -map('n', ';', ':', { desc = '; Command mode' }) - --- Select all -map('n', '', 'ggG') - -- Use jj as escape map('i', 'jj', '', opts) -map('i', 'jk', '', opts) -map('i', 'kj', '', opts) map('t', 'JJ', '', opts) --- Terminal Mappings -map('t', 'jk', '') -map('t', 'kj', '') -map('t', '', '') +-- VSCode style shortcuts +-- File operations +map('n', '', ':w', { desc = 'Save file' }) +map('i', '', ':wa', { desc = 'Save file' }) +map('n', '', ':q', { desc = 'Quit' }) +map('n', '', ':bd', { desc = 'Close buffer' }) + +-- Undo/Redo +map('n', '', 'u', { desc = 'Undo' }) +map('i', '', 'u', { desc = 'Undo' }) +map('n', '', '', { desc = 'Redo' }) +map('i', '', '', { desc = 'Redo' }) + +-- Select all +map('n', '', 'ggVG', { desc = 'Select all' }) +map('i', '', 'ggVG', { desc = 'Select all' }) + +-- Copy/Cut +map('v', '', 'y', { desc = 'Copy' }) +map('v', '', 'd', { desc = 'Cut' }) + +-- Line operations (VSCode style) +map('n', '', ':m .-2==', { desc = 'Move line up' }) +map('n', '', ':m .+1==', { desc = 'Move line down' }) +map('i', '', ':m .-2==gi', { desc = 'Move line up' }) +map('i', '', ':m .+1==gi', { desc = 'Move line down' }) +map('v', '', ":m '<-2gv=gv", { desc = 'Move selection up' }) +map('v', '', ":m '>+1gv=gv", { desc = 'Move selection down' }) + +-- VSCode-style line operations +map('n', '', 'O', { desc = 'Insert line above' }) +map('n', '', 'o', { desc = 'Insert line below' }) +map('i', '', 'O', { desc = 'Insert line above' }) + +-- Quick word operations +map('n', '', 'db', { desc = 'Delete word backward' }) +map('i', '', '', { desc = 'Delete word backward' }) +map('n', '', 'dw', { desc = 'Delete word forward' }) +map('i', '', 'dw', { desc = 'Delete word forward' }) + +-- Duplicate line +map('n', '', 'yykP', { desc = 'Duplicate line up' }) +map('n', '', 'yyp', { desc = 'Duplicate line down' }) +map('v', '', "y'', "y'>pgv", { desc = 'Duplicate selection down' }) + + +-- Line manipulation +map('n', '', '>>', { desc = 'Indent line' }) +map('n', '', '<<', { desc = 'Unindent line' }) +map('i', '', '>>', { desc = 'Indent line' }) +map('i', '', '<<', { desc = 'Unindent line' }) -- Visual overwrite paste map({ 'v', 'x' }, 'p', '"_dP', opts) -- Do not copy on x map({ 'v', 'x' }, 'x', '"_x', opts) +map('n', 'X', '"_D', opts) +map({ 'v', 'x' }, 'X', '"_d', opts) -- Increment/decrement map({ 'n', 'v', 'x' }, '-', '', opts) @@ -67,12 +105,6 @@ map({ 'v', 'x' }, 'K', ":move '<-2gv-gv", opts) -- Clear search, diff update and redraw map({ 'i', 'n' }, '', 'noh', { desc = 'Escape and clear hlsearch' }) --- Cursor navigation on insert mode -map('i', '', '', { desc = 'Move Cursor Left' }) -map('i', '', '', { desc = 'Move Cursor Left' }) -map('i', '', '', { desc = 'Move Cursor Left' }) -map('i', '', '', { desc = 'Move Cursor Left' }) - -- Consistent n/N search navigation map('n', 'n', "'Nn'[v:searchforward]", { expr = true, desc = 'Next search result' }) map('x', 'n', "'Nn'[v:searchforward]", { expr = true, desc = 'Next search result' }) @@ -90,25 +122,7 @@ map('i', ',', ',u') map('i', '.', '.u') map('i', ';', ';u') --- Move Lines -map('n', '', ':m .+1==', { desc = 'Move lines', silent = true }) -map('v', '', ":m '>+1gv=gv", { desc = 'Move lines', silent = true }) -map('i', '', ':m .+1==gi', { desc = 'Move lines', silent = true }) -map('n', '', ':m .-2==', { desc = 'Move lines', silent = true }) -map('v', '', ":m '<-2gv=gv", { desc = 'Move lines', silent = true }) -map('i', '', ':m .-2==gi', { desc = 'Move lines', silent = true }) -map('n', 'd', '"_d', { desc = 'Delete without replacing clipboard' }) -map('n', 'x', '"_x', { desc = 'Cut without replacing clipboard' }) -map('n', 'c', '"_c', { desc = 'Change without replacing clipboard' }) -map('v', 'p', '"_dP', { desc = 'Paste without replacing clipboard' }) --- Toggle relative numbers off or on (for code presentation) -map({ 'n', 'v' }, 'tn', 'set rnu!', {}) ---insert the following characters around the visual selection -map('v', '(', 's()Pll', { desc = 'wrap selection with parens' }) -map('v', '[', 's[]Pll', { desc = 'wrap selection with square braces' }) -map('v', '{', 's{}Pll', { desc = 'wrap selection with curly braces' }) -map('v', "'", "s''Pll", { desc = 'wrap selection with single quotes' }) -map('v', '"', 's""Pll', { desc = 'wrap selection with double quotes' }) +