nvim: simplify repetitive keymaps
This commit is contained in:
parent
93c7960620
commit
c5dfd52c2a
|
@ -4,22 +4,20 @@ end
|
|||
|
||||
vim.g.mapleader = ' ' -- <Leader>
|
||||
|
||||
local format = string.format
|
||||
|
||||
-- buffers
|
||||
map('n', '<Leader>b', ':buffers<CR>:buffer<Space>')
|
||||
map('n', '<M-Left>', ':bprevious<cr>')
|
||||
map('n', '<M-Right>', ':bnext<cr>')
|
||||
map('i', '<M-Left>', '<esc>:bprevious<cr>')
|
||||
map('i', '<M-Right>', '<esc>:bnext<cr>')
|
||||
for key, cmd in pairs({ Left = 'bprevious', Right = 'bnext' }) do
|
||||
map('n', format('<M-%s>', key), format(':%s<cr>', cmd))
|
||||
map('i', format('<M-%s>', key), format('<esc>:%s<cr>', cmd))
|
||||
end
|
||||
|
||||
--windows
|
||||
map('n', '<M-S-Left>', ':wincmd h<cr>')
|
||||
map('n', '<M-S-Down>', ':wincmd j<cr>')
|
||||
map('n', '<M-S-Up>', ':wincmd k<cr>')
|
||||
map('n', '<M-S-Right>', ':wincmd l<cr>')
|
||||
map('i', '<M-S-Left>', '<esc>:wincmd h<cr>')
|
||||
map('i', '<M-S-Down>', '<esc>:wincmd j<cr>')
|
||||
map('i', '<M-S-Up>', '<esc>:wincmd k<cr>')
|
||||
map('i', '<M-S-Right>', '<esc>:wincmd l<cr>')
|
||||
for key, letter in pairs({ Left = 'h', Down = 'j', Up = 'k', Right = 'l' }) do
|
||||
map('n', format('<M-S-%s>', key), format(':wincmd %s<cr>', letter))
|
||||
map('i', format('<M-S-%s>', key), format('<esc>:wincmd %s<cr>', letter))
|
||||
end
|
||||
|
||||
-- remove word
|
||||
map('n', '<M-BS>', 'db')
|
||||
|
@ -77,7 +75,6 @@ map('n', '<C-F>', '==') -- re-indent line
|
|||
|
||||
-- select text with shift + arrow
|
||||
for _, key in ipairs({ 'Left', 'Up', 'Down', 'Right' }) do
|
||||
local format = string.format
|
||||
map({ 'n', 'i' }, format('<S-%s>', key), format('<Esc>v<%s>', key))
|
||||
map({ 'v' }, format('<S-%s>', key), format('<%s>', key))
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user