69 lines
2.5 KiB
Lua
Raw Normal View History

2023-08-22 14:51:35 +00:00
local function map(mode, lhs, rhs, info)
2023-08-20 22:09:00 +00:00
vim.keymap.set(mode, lhs, rhs, { desc = info })
end
2023-08-19 17:22:56 +00:00
2023-08-21 17:19:37 +00:00
map("n", ";", ":", "Command mode")
2024-06-17 14:19:21 +00:00
map("n", "U", "<cmd>redo<cr>", "Redo")
map("n", "<Bslash>", "<cmd>ToggleWord<cr>", "Toggle word")
2024-03-09 21:03:35 +00:00
map("n", "<C-q>", "<cmd>close<cr>", "Close window")
2024-06-17 14:19:21 +00:00
map("n", "<leader>l", "<cmd>Lazy<cr>", "Lazy")
2024-06-23 09:23:10 +00:00
map({"n", "v"}, "q", "<cmd>qa<cr>", "Quit all")
2024-06-17 14:19:21 +00:00
map({"n", "v"}, "<leader>q", "<cmd>qa!<cr>", "Quit all")
map({"n", "i"}, "<esc>", "<cmd>noh<cr><esc>", "Clear search")
2024-06-21 14:42:08 +00:00
map({"n", "i", "s", "v"}, "<C-s>", "<cmd>w<cr><esc>", "Save file")
-- Add or delete empty lines
2024-06-23 09:23:10 +00:00
map("n", "<C-j>", "<cmd>set paste<cr>m`O<esc>``<cmd>set nopaste<cr>", "Add empty line above")
map("n", "<C-k>", "m`<cmd>-g/\\m^\\s*$/d<cr>``<cmd>noh<cr>", "Delete empty line above")
map("n", "<A-j>", "<cmd>set paste<cr>m`o<esc>``<cmd>set nopaste<cr>", "Add empty line below")
map("n", "<A-k>", "m`<cmd>+g/\\m^\\s*$/d<cr>``<cmd>noh<cr>", "Delete empty line below")
2024-06-21 14:42:08 +00:00
-- Quick movement
map("n", "J", "}", "Next paragraph")
map("n", "K", "{", "Previous paragraph")
2024-03-02 16:06:30 +00:00
-- Editing multiple instances
2024-06-17 14:19:21 +00:00
map("n", "<f2>", "*#:%s//<C-r><C-w>/g<left><left>", "Replace word under cursor")
map("v", "<f2>", "y/<C-r>\"<cr>N:%s//<C-r>\"/g<left><left>", "Replace selection")
2024-03-09 21:03:35 +00:00
map("n", "<f3>", "#*", "Search word under cursor")
2024-03-03 16:47:02 +00:00
map("v", "<f3>", "y/<C-r>\"<cr>N", "Search selection")
2024-03-05 12:28:48 +00:00
2024-06-17 14:19:21 +00:00
-- Line movement
map({"n", "v"}, "<C-b>", "^", "Beginning of line")
map("i", "<C-b>", "<esc>^i", "Beginning of line")
map({"i", "n", "v"}, "<C-e>", "<end>", "End of line")
2024-03-04 23:40:49 +00:00
2024-03-02 16:06:30 +00:00
-- Increasing and decreasing numbers
map("n", "+", "<C-a>", "Increase number")
map("n", "-", "<C-x>", "Decrease number")
map("n", "<kPlus>", "<C-a>", "Increase number")
map("n", "<kMinus>", "<C-x>", "Decrease number")
2023-08-19 17:22:56 +00:00
2024-06-17 14:19:21 +00:00
-- Indenting
map("n", "<Tab>", "V>gv<esc>")
map("n", "<S-Tab>", "V<gv<esc>")
map("v", "<Tab>", ">gv")
map("v", "<S-Tab>", "<gv")
2024-03-05 12:28:48 +00:00
2024-01-22 14:04:33 +00:00
-- Shift arrow selection
map("n", "<S-Up>", "v<Up>")
map("n", "<S-Down>", "v<Down>")
map("n", "<S-Left>", "v<Left>")
map("n", "<S-Right>", "v<Right>")
map("v", "<S-Up>", "<Up>")
map("v", "<S-Down>", "<Down>")
map("v", "<S-Left>", "<Left>")
map("v", "<S-Right>", "<Right>")
map("i", "<S-Up>", "<Esc>v<Up>")
map("i", "<S-Down>", "<Esc>v<Down>")
map("i", "<S-Left>", "<Esc>v<Left>")
map("i", "<S-Right>", "<Esc>v<Right>")
2024-03-09 21:03:35 +00:00
-- Window switching
map("n", "<A-Up>", "<C-w>k", "Move to the window above")
map("n", "<A-Down>", "<C-w>j", "Move to the window below")
map("n", "<A-Left>", "<C-w>h", "Move to the window on the left")
2024-06-21 14:42:08 +00:00
map("n", "<A-Right>", "<C-w>l", "Move to the window on the right")