local map = require("helpers.keys").map -- https://stackoverflow.com/questions/4256697/vim-search-and-highlight-but-do-not-jump -- search & highlight but do not jump map("n", "*", "keepjumps normal! mi*`i", "search forwards") map("n", "#", "keepjumps normal! mi#`i", "search backwards") -- save file as sudo on files that require root permission map("c", "w!!", 'execute "silent! write !sudo tee % >/dev/null" edit!', "save file as sudo", { silent = false }) -- replace ex mode with gq (format lines) map("n", "Q", "gq", "format lines") -- set formatprg to sentences, for prose map("n", "fp", ":set formatprg=~/.local/bin/sentences", "switch to sentences formatprg", { silent = false }) -- replace all is aliased to S. map("n", "S", ":%s//g", "replace all", { silent = false }) map("v", "S", ":s//g", "replace all", { silent = false }) -- jump to buffer map("n", "b", "ls:b", "jump to buffer") -- up and down are more logical with g.. map("n", "k", '(v:count == 0 ? "gk" : "k")', "up", { expr = true }) map("n", "j", '(v:count == 0 ? "gj" : "j")', "down", { expr = true }) map("i", "", "gka") map("i", "", "gja") -- space used to toggle folds, now it's x (because x is d) map("n", "", '"_x') -- separate cut and delete map("n", "x", "d") map("x", "x", "d") map("n", "xx", "dd") map("n", "X", "D") -- change into pwd of current buffer map("n", "cd", "lcd %:p:h:pwd", "cd to current buffer's pwd") -- call CreatePaper on word below cursor map("n", "np", 'gewi[[/papers/Ea]]bb:call CreatePaper(expand(""))', "vimwiki: new paper on word under cursor") -- link paper map("n", "lp", "gewi[[/papers/Ea]]", "vimwiki: link wrap word under cursor") -- call CreateReference on word below cursor map("n", "nr", 'call CreateReference(expand(""))', "vimwiki: new reference word under cursor") -- nr2char(10) is, of course, a newline character map("n", "yp", "call setreg('+', expand('%:h') . '/' . expand('%:t') . ':' . line('.') . nr2char(10) . getline('.'))", "yank the current line contents, filename and line number to clipboard") -- create a new note map("n", "nn", "call CreateNote()", "vimwiki: new note for slipbox") -- :%% to get current file path map('c', '%%', "getcmdtype() == ':' ? expand('%:h').'/' : '%%'", "get current file path", { expr = true, silent = false }) -- reselect visual selection after indent map('v', '>', '>gv') map('v', '<', 'ut", function() if vim.o.background == "dark" then vim.o.background = "light" else vim.o.background = "dark" end end, "toggle between light and dark background")