home ~ projects ~ socials

Change A Neovim Keymapping To Work With Delete

I use a moonlander and have remapped may keyboard considerally. I've updated a few Neovim keybindings as well to make things more natural.

One thing that took a bit to figure out is that keys that are mapped in Normal (n) mode don't take effect when you do something like hit the d key to do a deletion. Getting that to work requires making a second keymap for the o mode. For example:

vim.keymap.set('n', '(', "`}", {})
vim.keymap.set('o', '(', "`}", {})

vim.keymap.set('n', ')', "`{", {})
vim.keymap.set('o', ')', "`{", {})

This setup calls the a curly bracket of facing the opposite direction when I type a parenthesis. My parens have been remapped to be under j and k. With the remapping I can press j to jump down a line then shift the layer and hit it again to jump down a paragraph.

It works great.

-- end of line --