From ca6c534600c55a14708d12245e925f59bbcc4e94 Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Tue, 15 Feb 2022 15:40:23 +0100 Subject: [PATCH] vim: better macros to move lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The old macro got triggered unintentionally all the time, especially when leaving Insert mode. The reason was that one way terminals can emulate modifier key is by sending rapidly followed by the key that is supposed to be modified. So, when pressing to leave Insert mode and immediately pressing J to go down, my current line was moved – not the intended behavior and incredibly annoying. --- config/nvim/lua/fs/keymaps.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config/nvim/lua/fs/keymaps.lua b/config/nvim/lua/fs/keymaps.lua index e456fa6..9317a04 100644 --- a/config/nvim/lua/fs/keymaps.lua +++ b/config/nvim/lua/fs/keymaps.lua @@ -30,12 +30,12 @@ nmap { '.', 'tabnext', { silent = true } } nmap { ',', 'tabprevious', { silent = true } } -- move lines up and down -nmap { '', [[:move .+1==]] , { silent = true } } -nmap { '', [[:move .-2==]] , { silent = true } } -vmap { '', [[:move '>+1gv=gv]], { silent = true } } -vmap { '', [[:move '<-2gv=gv]], { silent = true } } -imap { '', [[:move .+1==gi]] , { silent = true } } -imap { '', [[:move .-2==gi]] , { silent = true } } +nmap { '', [[:move .+1==]] , { silent = true } } +nmap { '', [[:move .-2==]] , { silent = true } } +vmap { '', [[:move '>+1gv=gv]], { silent = true } } +vmap { '', [[:move '<-2gv=gv]], { silent = true } } +imap { '', [[:move .+1==gi]] , { silent = true } } +imap { '', [[:move .-2==gi]] , { silent = true } } -- move to begin/end of line in insert mode imap { '', '^' }