From fa68c6645412f1c6acf987f2ccc46b32a3733bee Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Thu, 14 Jul 2022 23:13:49 +0530 Subject: [PATCH] mappings: Do not use j,k mappings in operator mode --- lua/core/mappings.lua | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 6650f7e..5ad223f 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -7,17 +7,6 @@ end local M = {} M.general = { - [""] = { - -- Allow moving the cursor through wrapped lines with j, k, and - -- http ://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/ - -- empty mode is same as using :map - -- also don't use g[j|k] when in operator pending mode, so it doesn't alter d, y or c behaviour - ["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } }, - ["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } }, - [""] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } }, - [""] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } }, - }, - i = { -- go to beginning and end @@ -61,6 +50,15 @@ M.general = { " toggle theme", }, + + -- Allow moving the cursor through wrapped lines with j, k, and + -- http://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/ + -- empty mode is same as using :map + -- also don't use g[j|k] when in operator pending mode, so it doesn't alter d, y or c behaviour + ["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } }, + ["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } }, + [""] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } }, + [""] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } }, }, t = { @@ -68,6 +66,10 @@ M.general = { }, v = { + ["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } }, + ["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } }, + [""] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } }, + [""] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } }, -- Don't copy the replaced text after pasting in visual mode -- https://vim.fandom.com/wiki/Replace_a_word_with_yanked_text#Alternative_mapping_for_paste ["p"] = { 'p:let @+=@0:let @"=@0', opts = { silent = true } },