local tb = require("telescope.builtin") vim.g.mapleader = " " -- find Files vim.keymap.set("n", "f", tb.find_files, {}) -- find Text vim.keymap.set("n", "t", tb.live_grep, {}) -- find Buffers vim.keymap.set("n", "b", tb.buffers, {}) -- find keyMaps vim.keymap.set("n", "m", tb.keymaps, {}) -- find Command vim.keymap.set("n", "c", tb.commands, {}) -- find Documentation vim.keymap.set("n", "d", tb.man_pages, {}) -- open tree -- move and copy lines vim.keymap.set({ "i", "n" }, "", function() vim.api.nvim_feedkeys("ddkP", "x", false) end, {}) vim.keymap.set({ "i", "n" }, "", function() vim.api.nvim_feedkeys("ddp", "x", false) end, {}) vim.keymap.set({ "i", "n" }, "", function() vim.api.nvim_feedkeys("yyP", "x", false) end, {}) vim.keymap.set({ "i", "n" }, "", function() vim.api.nvim_feedkeys("yyp", "x", false) end, {}) -- toggle function signature -- format and vplit remaps vim.keymap.set({ "n", "i" }, "", vim.cmd.Format, {}) vim.keymap.set({ "i", "n" }, "", vim.cmd.vsplit, {}) -- vscode fold and unfold -- clangd switch source/header -- goto mappings vim.keymap.set("n", "gd", vim.lsp.buf.definition, {}) vim.keymap.set("n", "gD", vim.lsp.buf.declaration, {}) vim.keymap.set("n", "gi", vim.lsp.buf.implementation, {}) vim.keymap.set("n", "", vim.lsp.buf.code_action, {}) -- lsp rename vim.keymap.set("n", "", vim.lsp.buf.rename, {}) vim.keymap.set({ "n", "v" }, ";", ":") vim.keymap.set("n", "/", ":call eregex#toggle()", { noremap = true, }) vim.keymap.set("n", "w", ":SudaWrite", { noremap = true, }) vim.keymap.set("v", "h", ":S/", { noremap = true, }) vim.keymap.set("n", "h", ":%S/", { noremap = true, }) -- open command line with the path of current buffer already inserted vim.keymap.set("n", "e", function() -- print((":e " .. string.gsub(vim.fn.expand("%"), '(.*/)(.*)', '%1'))); vim.api.nvim_feedkeys((":e " .. string.gsub(vim.fn.expand("%"), "(.*/)(.*)", "%1")), "L", false) end) -- training vim.keymap.set("n", "", ':echoe "Use h"') vim.keymap.set("n", "", ':echoe "Use l"') vim.keymap.set("n", "", ':echoe "Use k"') vim.keymap.set("n", "", ':echoe "Use j"') vim.keymap.set("i", "", ':echoe "Use h"i') vim.keymap.set("i", "", ':echoe "Use l"i') vim.keymap.set("i", "", ':echoe "Use k"i') vim.keymap.set("i", "", ':echoe "Use j"i') -- https://stackoverflow.com/questions/1841480/how-to-use-lowercase-marks-as-global-in-vim -- Use lowercase for global marks and uppercase for local marks. local low = function(i) return string.char(97+i) end local upp = function(i) return string.char(65+i) end for i=0,25 do vim.keymap.set("n", "m"..low(i), "m"..upp(i)) end for i=0,25 do vim.keymap.set("n", "m"..upp(i), "m"..low(i)) end for i=0,25 do vim.keymap.set("n", "'"..low(i), "'"..upp(i)) end for i=0,25 do vim.keymap.set("n", "'"..upp(i), "'"..low(i)) end