local opts = { noremap = true, silent = true } vim.g.mapleader = " " vim.g.maplocalleader = " " vim.keymap.set("v", "J", ":m '>+1gv=gv", { desc = "moves lines down in visual selection" }) vim.keymap.set("v", "K", ":m '<-2gv=gv", { desc = "moves lines up in visual selection" }) vim.keymap.set("n", "J", "mzJ`z") vim.keymap.set("n", "", "zz", { desc = "move down in buffer with cursor centered" }) vim.keymap.set("n", "", "zz", { desc = "move up in buffer with cursor centered" }) vim.keymap.set("n", "n", "nzzzv") vim.keymap.set("n", "N", "Nzzzv") -- select single or multiple lines and move them up or down without having to re-enter visual mode vim.keymap.set("v", "<", "", ">gv", opts) -- Paste without replacing clipboard content by x. vim.keymap.set("x","p", [["_dP]]) -- tab stuff vim.keymap.set("n", "to", "tabnew") --open new tab vim.keymap.set("n", "tx", "tabclose") --close current tab vim.keymap.set("n", "tn", "tabn") --go to next vim.keymap.set("n", "tp", "tabp") --go to pre vim.keymap.set("n", "tf", "tabnew %") --open current tab in new tab --split management vim.keymap.set("n", "sv", "v", { desc = "Split window vertically" }) -- split window vertically vim.keymap.set("n", "sh", "s", { desc = "Split window horizontally" }) -- split window horizontally vim.keymap.set("n", "se", "=", { desc = "Make splits equal size" }) -- make split windows equal width & height -- close current split window vim.keymap.set("n", "sx", "close", { desc = "Close current split" }) -- vim tmux settings local M = {} M.general = { n = { [""] = { " TmuxNavigateLeft", "window left"}, [""] = { " TmuxNavigateRight", "window right"}, [""] = { " TmuxNavigateDown", "window down"}, [""] = { " TmuxNavigateUp", "window up"}, } } -- Replace the word cursor is on globally vim.keymap.set("n", "s", [[:%s/\<\>//gI]], { desc = "Replace word cursor is on globally" }) -- Copy filepath to the clipboard vim.keymap.set("n", "fp", function() local filePath = vim.fn.expand("%:~") -- Gets the file path relative to the home directory vim.fn.setreg("+", filePath) -- Copy the file path to the clipboard register print("File path copied to clipboard: " .. filePath) end, { desc = "Copy file path to clipboard" }) -- Toggle LSP diagnostics visibility local isLspDiagnosticsVisible = true vim.keymap.set("n", "lx", function() isLspDiagnosticsVisible = not isLspDiagnosticsVisible vim.diagnostic.config({ virtual_text = isLspDiagnosticsVisible, underline = isLspDiagnosticsVisible }) end, { desc = "Toggle LSP diagnostics" })