local function map(mode, shortcut, command) vim.api.nvim_set_keymap(mode, shortcut, command, { noremap = true, silent = true }) end local function nmap(shortcut, command) map("n", shortcut, command) end local function vmap(shortcut, command) map("v", shortcut, command) end local function imap(shortcut, command) map("i", shortcut, command) end -- Quickly save/quit vim nmap("w", ":w") nmap("q", ":q") nmap("e", ":bdelete") -- Move line under the cursor up and down nmap("", ":m .-2==") nmap("", ":m .+1==") vmap("K", ":m '<-2gv=gv") vmap("J", ":m '>+1gv=gv") -- Remove search highlighting nmap("nh", ":nohl") -- Escape from terminal map("t", "", "") -- Open splits nmap("sv", ":vs") nmap("sh", ":sp") -- Move focus between splits nmap("h", "h") nmap("j", "j") nmap("k", "k") nmap("l", "l") -- Resize splits nmap("", ":resize -2") nmap("", ":resize +2") nmap("", ":vert resize -10") nmap("", ":vert resize +10") -- File tree nmap("b", ":NvimTreeToggle") -- Telescope nmap("p", ":Telescope") nmap("f", ":Telescope find_files") -- LSP nmap("K", "lua vim.lsp.buf.hover()") nmap("gd", "lua vim.lsp.buf.definition()") nmap(".", "lua vim.lsp.buf.code_action()") nmap("", "lua vim.lsp.buf.rename()") -- Tabs nmap("1", ":BufferLineGoToBuffer 1") nmap("2", ":BufferLineGoToBuffer 2") nmap("3", ":BufferLineGoToBuffer 3") nmap("4", ":BufferLineGoToBuffer 4") nmap("5", ":BufferLineGoToBuffer 5") nmap("6", ":BufferLineGoToBuffer 6") nmap("7", ":BufferLineGoToBuffer 7") nmap("8", ":BufferLineGoToBuffer 8") nmap("9", ":BufferLineGoToBuffer 9") -- Terminal nmap("t", ":ToggleTerminal") -- Git nmap("gg", ":G")