nmap("", "") vim.g.mapleader = " " vim.g.maplocalleader = " " nmap("Y", "yy") nmap("", "", { desc = "Switch to last buffer" }) nmap("", ":vertical resize +3", { desc = "Resize window" }) nmap("", ":vertical resize -3", { desc = "Resize window" }) nmap("", ":resize +3", { desc = "Resize window" }) nmap("", ":resize -3", { desc = "Resize window" }) vim.cmd([[ nnoremap nnoremap ]]) nmap("n", "nzz", { desc = "Move to next search match" }) nmap("N", "Nzz", { desc = "Move to previous search match" }) nmap("*", "*zz", { desc = "Move to next search match" }) nmap("#", "#zz", { desc = "Move to previous search match" }) nmap("g*", "g*zz", { desc = "Move to next search match" }) nmap("g#", "g#zz", { desc = "Move to previous search match" }) -- stay in indent mode vmap("<", "", ">gv", { desc = "Indent right" }) -- keep register after paste map("x", "p", [["_dP]]) map({ "n", "o", "x" }, "", "^", { desc = "Move to first non-blank character" }) map({ "n", "o", "x" }, "", "g_", { desc = "Move to last non-blank character" }) nmap("q", ":q", { desc = "Quit" }) nmap("Q", function() vim.api.nvim_command("bd!|qall!") end, { desc = "Quit all" }) -- create a user command to save without formatting :noa w vim.api.nvim_create_user_command("W", function() -- if buffer is empty, don't save if vim.fn.empty(vim.fn.expand("%:t")) == 1 then return vim.notify("Buffer is empty, not saving", vim.log.levels.ERROR) end vim.api.nvim_command("noa w") end, { nargs = 0, desc = "Save without formatting" }) -- move lines vmap("J", ":m '>+1gv=gv", { desc = "Move lines down" }) vmap("K", ":m '<-2gv=gv", { desc = "Move lines up" }) -- undo tree nmap("u", vim.cmd.UndotreeToggle) -- nnoremap yl :let @" = expand("%:p") nmap("yl", function() local file = vim.fn.expand("%:p") print("Copied path to clipboard: " .. file) -- copy to os clipboard vim.fn.setreg("+", file) end, { desc = "Copy file path to clipboard" }) nmap("x", "!chmod +x %", { desc = "Make file executable" }) vim.g.user_emmet_leader_key = "," nmap("gp", "Git push", { desc = "Git push" }) -- reset cmdheight nmap("ch", function() vim.o.cmdheight = 1 end, { desc = "Reset cmdheight" }) nmap("w", function() vim.api.nvim_command("w") end, { desc = "Save" }) nmap("W", function() vim.api.nvim_command("wa") end, { desc = "Save all" }) -- format json using jq nmap("jq", ":%!jq '.'", { desc = "Format json using jq" }) vmap("jq", ":!jq '.'", { desc = "Format json using jq" }) -- Navigate quickfix list nmap("qj", "cnext", { desc = "Next quickfix item" }) nmap("qk", "cprev", { desc = "Previous quickfix item" }) nmap("", "nohlsearch", { desc = "Clear search highlights" })