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.
 
 
 

53 lines
2.2 KiB

-- Don't copy "c" changes to primary register
vim.keymap.set("n", "c", '"_c', { desc = "Prevent copying to primary register" })
-- Move lines up and down
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
-- Easily open splits
vim.keymap.set("n", "<leader>hs", "<cmd>split<cr>", { desc = "Open horizontal spilt" })
vim.keymap.set("n", "<leader>vs", "<cmd>vsplit<cr>", { desc = "Open vertical spilt" })
-- Spell-check
vim.keymap.set("n", "<leader>o", function()
vim.cmd("setlocal spell! spelllang=en_au")
end, { desc = "Toggle spell check" })
-- Map Q to run q macro
vim.keymap.set("n", "Q", "@q", { desc = "Remap Q to run @q macro" })
vim.keymap.set("x", "Q", ":norm @q<CR>", { desc = "Remap Q to run @q macro" })
-- Keep highlight when indenting
vim.keymap.set("v", "<", "<gv", { desc = "Keep highlight when indenting" })
vim.keymap.set("v", ">", ">gv", { desc = "Keep highlight when indenting" })
vim.keymap.set("n", "<leader>tN", "<cmd>tabnew<CR>", { desc = "New tab" })
vim.keymap.set("n", "<leader>tn", "<cmd>tabnext<CR>", { desc = "Next tab" })
vim.keymap.set("n", "<leader>tp", "<cmd>tabprevious<CR>", { desc = "Previous tab" })
vim.keymap.set("x", "<leader>p", '"_dP', { desc = "Delete into black hole register" })
vim.keymap.set("n", "<leader>d", '"_d', { desc = "Delete into black hole register" })
vim.keymap.set("v", "<leader>d", '"_d', { desc = "Delete into black hole register" })
-- Keep page scroll centered
vim.keymap.set("n", "<C-d>", "<C-d>zz", { desc = "Scroll down half page" })
vim.keymap.set("n", "<C-u>", "<C-u>zz", { desc = "Scroll up half page" })
-- Keep cursor centered
vim.keymap.set("n", "n", "nzzzv", { desc = "Next search result" })
vim.keymap.set("n", "N", "Nzzzv", { desc = "Previous search result" })
-- Keep cursor centered when jumping through quickfix list
vim.keymap.set("n", "<leader>k", "<cmd>cprev<CR>zz", { desc = "Previous item in quickfix list" })
vim.keymap.set("n", "<leader>j", "<cmd>cnext<CR>zz", { desc = "Next item in quickfix list" })
-- Easily run global search and replace
vim.keymap.set(
"n",
"<leader>rr",
[[:%s/\<<C-r><C-w>\>//gI<Left><Left><Left>]],
{ desc = "Search and replace for word under cursor" }
)
vim.keymap.set("t", "<C-space>", "<C-\\><C-n>", { silent = true })