diff options
Diffstat (limited to '.config/nvim/lua/config/keymaps.lua')
| -rw-r--r-- | .config/nvim/lua/config/keymaps.lua | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/.config/nvim/lua/config/keymaps.lua b/.config/nvim/lua/config/keymaps.lua new file mode 100644 index 0000000..89a8c79 --- /dev/null +++ b/.config/nvim/lua/config/keymaps.lua @@ -0,0 +1,108 @@ +local set = vim.keymap.set + +local function remapkey(mode, key, action) + vim.keymap.set(mode, key, action, { noremap = true, silent = true }) +end + +-- dagnostic popup +set("n", "<leader>e", ":lua vim.diagnostic.open_float()<CR>") + +-- ESC insert to normal ctrl jk +-- set("i", "<C-j><C-k>", "<ESC>") + +-- set("v", "t", "!pandoc -f csv -t commonmark_x<CR>") +set("v", "<m-t>", "!pandoc -f csv -t commonmark_x<CR>") + +-- common save shortcuts +set("i", "<C-s>", "<ESC>:w<cr>a") +set("n", "<C-s>", ":w<cr>") + +-- don't move the cursor +set("n", "J", "mzJ`z") + +-- keep cursor in the middle +set("n", "<C-d>", "<C-d>zz") +set("n", "<C-u>", "<C-u>zz") +set("n", "n", "nzzzv") +set("n", "N", "Nzzzv") + +-- preserve clipboard when pasting +set("x", "<space>p", '"_dp') + +-- sane movement with wrap o n +remapkey({ "n", "v" }, "j", "gj") +remapkey({ "n", "v" }, "k", "gk") +remapkey({ "n", "v" }, "<Down>", "gj") +remapkey({ "n", "v" }, "<Up>", "gk") +remapkey("i", "<Down>", "<C-o>gj") +remapkey("i", "<Up>", "<C-o>gk") + +-- terminal shortcuts +remapkey("i", "<C-t>", "<Esc>:term<CR>A") +remapkey("n", "<C-t", ":term<CR>A") + +-- tab key in visual mode +set("v", "<Tab>", ">gv") +set("v", "<S-Tab>", "<gv") + +-- visually select the characters that are wanted in the search, then type // to search for the next occurrence of the selected text +remapkey("v", "//", "y/\\V<C-R>=escape(@\",'/\\')<CR><CR>") + +-- no ex mode etc +remapkey("n", "Q", "<Nop>") +remapkey("n", "<C-f>", "<Nop>") + +-- center current line +remapkey("n", "cc", ":center<CR>") + +-- write to files with root privileges +set("c", "w!!", ":w !sudo tee % >/dev/null") + +-- blamer +-- set("", "<C-b>", ":BlamerToggle<CR>") + +-- delete to void register +set({ "n", "v" }, "<leader>d", '"_d') + +-- quickfix list +set("n", "<C-x>", "<cmd>cnext<CR>zz") +set("n", "C-c>", "<cmd>cprev<CR>zz") +set("n", "<leader>x", "<cmd>lnext<CR>zz") +set("n", "<leader>c", "<cmd>lprev<CR>zz") + +-- typo fix +set("i", "<F1>", "<Esc>") +set("n", "q:", ":q<CR>") +vim.cmd([[ + ia tongiht tonight + ia htese these + ia od do + ia nothign nothing + ia htey they + ia htem them + ia iwth with + ia maxium maximum + ia funtcion function + ia fucntion function + ia funciton function + ia dfe def + ia edn end + ia teh the + ia hte the + ia htis this + ia tihs this + ia taht that + ia retunr return + ia reutrn return + ia eariler earlier + ia ulness unless + ia ahve have + ia chatper chapter + ia colmun column + ia amster master + ia orgiin origin + ia somehting something + ia hting thing + ia orgniaztion organization + ia orgnization organization +]]) |
