local function remap(modes, from, to) modes:gsub('.', function(c) vim.keymap.set(c, from, to) end) end vim.g.mapleader = ' ' -- Make adjustments for my custom keyboard layout remap('nv', '€', '$') remap('nv', ')', '0') remap('n', '<', '<<') remap('n', '>', '>>') -- Open netrw remap('n', 'rw', vim.cmd.Ex) -- Better frame navigation remap('n', '', 'h') remap('n', '', 'j') remap('n', '', 'k') remap('n', '', 'l') -- I prefer visual-line mode on ‘V’ remap('n', 'V', '') remap('n', '', 'V') -- Move selections up and down remap('v', '', ":m '>+1gv=gv") remap('v', '', ":m '<-2gv=gv") -- Don’t move cursor with various commands remap('n', 'J', 'mzJ`z') remap('n', '', 'zz') remap('n', '', 'zz') remap('n', 'n', 'nzzzv') remap('n', 'N', 'Nzzzv') -- Paste and delete without clobbering primary register remap('x', 'p', '"_dP') remap('nv', 'd', '"_d') -- Copy to system clipboard remap('nv', 'y', '"+y') remap('n', 'Y', '"+Y')