You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
2.3 KiB

  1. vim.keymap.set("i", "jk", "<esc>", {})
  2. -- Don't copy "c" changes to primary register
  3. vim.keymap.set("n", "c", '"_c', { desc = "Prevent copying to primary register" })
  4. -- Move lines up and down
  5. vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
  6. vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
  7. -- Easily open splits
  8. vim.keymap.set("n", "<leader>bs", "<cmd>split<cr>", { desc = "Open horizontal spilt" })
  9. vim.keymap.set("n", "<leader>vs", "<cmd>vsplit<cr>", { desc = "Open vertical spilt" })
  10. -- Spell-check
  11. vim.keymap.set("n", "<leader>o", function()
  12. vim.cmd("setlocal spell! spelllang=en_au")
  13. end, { desc = "Toggle spell check" })
  14. -- Map Q to run q macro
  15. vim.keymap.set("n", "Q", "@q", { desc = "Remap Q to run @q macro" })
  16. vim.keymap.set("x", "Q", ":norm @q<CR>", { desc = "Remap Q to run @q macro" })
  17. -- Keep highlight when indenting
  18. vim.keymap.set("v", "<", "<gv", { desc = "Keep highlight when indenting" })
  19. vim.keymap.set("v", ">", ">gv", { desc = "Keep highlight when indenting" })
  20. vim.keymap.set("n", "<leader>tN", "<cmd>tabnew<CR>", { desc = "New tab" })
  21. vim.keymap.set("n", "<leader>tn", "<cmd>tabnext<CR>", { desc = "Next tab" })
  22. vim.keymap.set("n", "<leader>tp", "<cmd>tabprevious<CR>", { desc = "Previous tab" })
  23. vim.keymap.set("x", "<leader>p", '"_dP', { desc = "Delete into black hole register" })
  24. vim.keymap.set("n", "<leader>d", '"_d', { desc = "Delete into black hole register" })
  25. vim.keymap.set("v", "<leader>d", '"_d', { desc = "Delete into black hole register" })
  26. -- Keep page scroll centered
  27. vim.keymap.set("n", "<C-d>", "<C-d>zz", { desc = "Scroll down half page" })
  28. vim.keymap.set("n", "<C-u>", "<C-u>zz", { desc = "Scroll up half page" })
  29. -- Keep cursor centered
  30. vim.keymap.set("n", "n", "nzzzv", { desc = "Next search result" })
  31. vim.keymap.set("n", "N", "Nzzzv", { desc = "Previous search result" })
  32. -- Keep cursor centered when jumping through quickfix list
  33. vim.keymap.set("n", "<leader>K", "<cmd>cprev<CR>zz", { desc = "Previous item in quickfix list" })
  34. vim.keymap.set("n", "<leader>J", "<cmd>cnext<CR>zz", { desc = "Next item in quickfix list" })
  35. -- Easily run global search and replace
  36. vim.keymap.set(
  37. "n",
  38. "<leader>rr",
  39. [[:%s/\<<C-r><C-w>\>//gI<Left><Left><Left>]],
  40. { desc = "Search and replace for word under cursor" }
  41. )
  42. vim.keymap.set("t", "<C-space>", "<C-\\><C-n>", { silent = true })