vim.g.mapleader = " " local function map(mode, lhs, rhs, info) vim.keymap.set(mode, lhs, rhs, { desc = info }) end -- Enter command mode without pressing shift map("n", ";", ":", "Command mode") -- Undo with u, Redo with U map("n", "U", "redo", "Redo") -- Quit with q like any other terminal app map({"n", "v"}, "q", "qa", "Quit all") map({"n", "v"}, "Q", "qa!", "Force quit") -- Clear search with Esc map({"n", "i"}, "", "noh", "Clear search") -- Ctrl S to save the file from any mode map({"n", "i", "s", "v"}, "", "w", "Save file") -- Grab the line and move it up/down map("n", "", "set pastem`O``set nopaste", "Add empty line above") map("n", "", "m`-g/\\m^\\s*$/d``noh", "Delete empty line above") -- Grab the line below and move it up/down map("n", "", "set pastem`o``set nopaste", "Add empty line below") map("n", "", "m`+g/\\m^\\s*$/d``noh", "Delete empty line below") -- Horizontal movement map({"n", "v"}, "H", "^", "Beginning of line") map({"n", "v"}, "L", "", "End of line") -- Vertical movement map({"n", "v"}, "J", "}", "Next paragraph") map({"n", "v"}, "K", "{", "Previous paragraph") -- Indenting map("n", "", "V>gv") map("n", "", "V") map("v", "", ">gv") map("v", "", "", "ToggleWord", "Toggle word") -- Increasing and decreasing numbers map("n", "+", "", "Increase number") map("n", "-", "", "Decrease number") map("n", "", "", "Increase number") map("n", "", "", "Decrease number") -- Replace all instances map("n", "", "*#:%s///g", "Replace word under cursor") map("v", "", "y/\"N:%s//\"/g", "Replace selection") -- Search all instances map("n", "", "#*", "Search word under cursor") map("v", "", "y/\"N", "Search selection") -- Window management map("n", "", "k", "Move to the window above") map("n", "", "j", "Move to the window below") map("n", "", "h", "Move to the window on the left") map("n", "", "l", "Move to the window on the right") map("n", "", "close", "Close window")