From e61dd9685ba5700ba0ea1e211fd1817bbb610a44 Mon Sep 17 00:00:00 2001 From: Nami Lauckner Date: Fri, 31 Jul 2026 20:19:35 +0200 Subject: [PATCH] improve remap docu --- lua/nami/remap.lua | 72 +++++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/lua/nami/remap.lua b/lua/nami/remap.lua index 365f4cf..3f015d4 100644 --- a/lua/nami/remap.lua +++ b/lua/nami/remap.lua @@ -1,9 +1,10 @@ -- vim.g.mapleader = " " -- This has to be configured inside lazy.lua due to telescope loading before this takes effect -vim.cmd("command! W w") - --- Navigation +---------------- +-- Navigation -- +---------------- +vim.cmd("command! W w") -- I'm missing w for W too much vim.keymap.set("n", "Q", "", { desc = "Do not quit" }) -- Do not quit :D vim.keymap.set("i", "", "") -- Exit insert mode with C-c vim.keymap.set("n", "", "silent !tmux display-popup -E \"tmuxss -i\"") -- open tmuxss switcher @@ -12,32 +13,24 @@ vim.keymap.set("n", "", "copen"); vim.keymap.set("t", "", "") -- use Esc to escape terminal -vim.keymap.set("n", "", "zz") -- Move up a page while keeping the cursor centered -vim.keymap.set("n", "", "zz") -- Move down a page while keeping the cursor centered +-- Buffer +vim.keymap.set("n", "", "zz") -- Move up a page while keeping the cursor centered +vim.keymap.set("n", "", "zz") -- Move down a page while keeping the cursor centered -vim.keymap.set("n", "n", "nzzzv") -- Jump to next occurance and center cursor -vim.keymap.set("n", "N", "Nzzzv") -- Jump to previous occurance and center cursor +vim.keymap.set("n", "n", "nzzzv") -- Jump to next occurance and center cursor +vim.keymap.set("n", "N", "Nzzzv") -- Jump to previous occurance and center cursor -vim.keymap.set("n", "", "cprevzz") -- Previous Quickfixlist entry -vim.keymap.set("n", "", "cnextzz") -- Next Quickfixlist entry +-- Quickfixlist +vim.keymap.set("n", "", "cprevzz") -- Previous Quickfixlist entry +vim.keymap.set("n", "", "cnextzz") -- Next Quickfixlist entry -vim.keymap.set("n", "", "tabnext +") -- Next tab -vim.keymap.set("n", "", "tabnext -") -- Previous Tab -vim.keymap.set("n", "", "tabnew") -- Create new Tab -vim.keymap.set("n", "", "tabclose") -- Close the current Tab - --- Text editing -vim.keymap.set("v", "J", ":m '>+1gv=gv") -- Move selected text up one line -vim.keymap.set("v", "K", ":m '<-2gv=gv") -- Move selected text down one line - -vim.keymap.set("n", "J", "mzJ`z") -- Remove newline characte on current line - -vim.keymap.set("n", "c", ":w:!cargorun") -- Quick Cargo run - -vim.keymap.set("n", "f", function() - vim.lsp.buf.format() -end) +-- Tabs +vim.keymap.set("n", "", "tabnext +") -- Next tab +vim.keymap.set("n", "", "tabnext -") -- Previous Tab +vim.keymap.set("n", "", "tabnew") -- Create new Tab +vim.keymap.set("n", "", "tabclose") -- Close the current Tab +-- Disable mouse -- fuck this thing for _, mode in ipairs({ "n", "v", "i" }) do vim.keymap.set(mode, "", function() end) @@ -46,6 +39,18 @@ for _, mode in ipairs({ "n", "v", "i" }) do vim.keymap.set(mode, "<4-RightMouse>", function() end) end +------------------ +-- Text editing -- +------------------ +vim.keymap.set("v", "J", ":m '>+1gv=gv") -- Move selected text up one line +vim.keymap.set("v", "K", ":m '<-2gv=gv") -- Move selected text down one line + +vim.keymap.set("n", "J", "mzJ`z") -- Remove newline characte on current line + +vim.keymap.set("n", "f", function() -- Format buffer + vim.lsp.buf.format() +end) + -- Goated: Edit the word under the cursor using a substitute vim.keymap.set("n", "s", ":%s/\\<\\>//gI") @@ -57,12 +62,14 @@ vim.keymap.set("n", "Y", "\"+Y") -- Delete to void register (no clipboard) vim.keymap.set("v", "d", "\"_d") vim.keymap.set("v", "dd", "\"_d") --- currently conflict with searches --- vim.keymap.set("x", "P", "\"_dP") -- Paste before without moving selection into the yank register --- vim.keymap.set("x", "p", "\"_dp") -- Paste after without moving selection into the yank register +-- currently conflicting with searches +vim.keymap.set("x", "P", "\"_dP") -- Paste before without moving selection into the yank register +vim.keymap.set("x", "p", "\"_dp") -- Paste after without moving selection into the yank register --- Macros -vim.keymap.set("n", "x", "!chmod +x %", { silent = true }) +------------ +-- Macros -- +------------ +vim.keymap.set("n", "c", ":w:!cargorun") -- Quick Cargo run -- format a markdown table inside visual selection vim.api.nvim_create_user_command("Mdtf", function(opts) @@ -72,11 +79,16 @@ end, { }) vim.keymap.set("v", "mt", ":!column -t -s '|' -o '|'", { desc = "Format markdown table" }) +-- Scripting +vim.keymap.set("n", "x", "!chmod +x %", { silent = true }) -- Make the current file executable + -- Lua editing vim.keymap.set("n", "l", "source %") -- source the current buffer vim.keymap.set("n", "l", ":.lua") -- source the current line vim.keymap.set("v", "l", ":lua") -- source the visual selection +-- Swap all occurances of two sequences with each other inside a file +-- This may be a bit buggy still local function swap_words() local start = vim.fn.getpos("'<")[2] local finish = vim.fn.getpos("'>")[2]