vim: better macros to move lines
The old macro got triggered unintentionally all the time, especially when leaving Insert mode. The reason was that one way terminals can emulate <Alt> modifier key is by sending <Esc> rapidly followed by the key that is supposed to be modified. So, when pressing <Esc> to leave Insert mode and immediately pressing J to go down, my current line was moved – not the intended behavior and incredibly annoying.
This commit is contained in:
parent
c3a02944b3
commit
ca6c534600
1 changed files with 6 additions and 6 deletions
|
@ -30,12 +30,12 @@ nmap { '<leader>.', '<cmd>tabnext<cr>', { silent = true } }
|
|||
nmap { '<leader>,', '<cmd>tabprevious<cr>', { silent = true } }
|
||||
|
||||
-- move lines up and down
|
||||
nmap { '<A-j>', [[:move .+1<cr>==]] , { silent = true } }
|
||||
nmap { '<A-k>', [[:move .-2<cr>==]] , { silent = true } }
|
||||
vmap { '<A-j>', [[:move '>+1<cr>gv=gv]], { silent = true } }
|
||||
vmap { '<A-k>', [[:move '<-2<cr>gv=gv]], { silent = true } }
|
||||
imap { '<A-j>', [[<esc>:move .+1<cr>==gi]] , { silent = true } }
|
||||
imap { '<A-k>', [[<esc>:move .-2<cr>==gi]] , { silent = true } }
|
||||
nmap { '<c-a-j>', [[:move .+1<cr>==]] , { silent = true } }
|
||||
nmap { '<c-a-k>', [[:move .-2<cr>==]] , { silent = true } }
|
||||
vmap { '<c-a-j>', [[:move '>+1<cr>gv=gv]], { silent = true } }
|
||||
vmap { '<c-a-k>', [[:move '<-2<cr>gv=gv]], { silent = true } }
|
||||
imap { '<c-a-j>', [[<esc>:move .+1<cr>==gi]] , { silent = true } }
|
||||
imap { '<c-a-k>', [[<esc>:move .-2<cr>==gi]] , { silent = true } }
|
||||
|
||||
-- move to begin/end of line in insert mode
|
||||
imap { '<c-a>', '<c-o>^' }
|
||||
|
|
Loading…
Add table
Reference in a new issue