nvim/lua/my_keymappings.lua
2022-07-01 16:44:37 +02:00

36 lines
1.4 KiB
Lua

vim.g.mapleader = ','
local opts = { noremap = true, silent = true }
vim.keymap.set('n', '<space>', 'nil', opts)
-- Tabs
vim.keymap.set('n', '<S-Right>', ':tabnext<CR>', opts)
vim.keymap.set('n', '<S-Left>', ':tabprevious<CR>', opts)
-- Split movement
vim.keymap.set('n', '<A-Up>', ':wincmd k<CR>', opts)
vim.keymap.set('n', '<A-Down>', ':wincmd j<CR>', opts)
vim.keymap.set('n', '<A-Left>', ':wincmd h<CR>', opts)
vim.keymap.set('n', '<A-Right>', ':wincmd l<CR>', opts)
vim.keymap.set('n', '<C-S>', ':wa | wshada<CR>')
-- Linewrap and jumping
vim.keymap.set({ 'n', 'x' }, 'k', 'gk', opts)
vim.keymap.set({ 'n', 'x' }, 'j', 'gj', opts)
vim.keymap.set({ 'n', 'x' }, '0', 'g0', opts)
vim.keymap.set({ 'n', 'x' }, '$', 'g$', opts)
vim.keymap.set({ 'n', 'x' }, '<Up>', 'gk', opts)
vim.keymap.set({ 'n', 'x' }, '<Down>', 'gj', opts)
vim.keymap.set({ 'n', 'x' }, '<Home>', 'g<Home>', opts)
vim.keymap.set({ 'n', 'x' }, '<End>', 'g<End>', opts)
vim.keymap.set('x', '<', '<gv')
vim.keymap.set('x', '>', '>gv')
-- Highlight word under cursor
vim.keymap.set('n', "'", ':let @/=\'\\<<C-R>=expand("<cword>")<CR>\\>\'<CR>:set hls<CR>', { noremap = true, silent = true })
-- vim.keymap.set('v', "'", "y:let @/='<C-R>=escape(@\",'/\\')<CR>'<CR>:set hls<CR>")
vim.keymap.set('x', "'", "y:let @/='<C-R>=escape(@\",'/\\')<CR>'<CR>:set hls<CR>", { noremap = true, silent = true })
-- Close Buffer
vim.keymap.set('n', '<C-w>', ':bd<CR>')