Some handy shortcuts for Vim

March 23, 2022

Over the past two years where I’ve been using Neovim exclusively, I settled upon a few keybindings that I found on the internet and that I came to appreciate. I should note that I am now using Telescope instead of vim-fzf, and so many mappings are provided by this Neovim plugin:

See also this related post: Custom Vim shortcuts (2/n).

In addition to the above, I also have handy shortcuts for Magma, vim-surround-like stuff,3 etc.

Finally, I don’t really like or need snippet engines, so I just defined some handy abbreviations, like this:

iabbrev +w []()
iabbrev +@
iabbrev +% --8<--------<CR>-------->8--<Up>
iabbrev +' ``
iabbrev +" ```<CR><CR>```<Esc>2k
iabbrev +:: ¯\_()_
iabbrev +:( ಠ_ಠ
iabbrev +:) ಠ‿ಠ

♪ Charlie Haden • Conception

  1. <c-g>u<Esc>[s1z=`]a<c-g>u (Credit: Gilles Castel, see also Francis Tseng or SO), and :let @s='\<'.expand('<cword>').'\>'<CR>:%s/<C-r>s//<Left> and sy:%s/<C-r>s//<Left> (Credit: bluz71↩︎

  2. vip:sort u<CR> in visual mode and :sort u<CR> in normal mode (Credit: strager↩︎

  3. E.g., vnoremap _( :call text#surround('(', ')')<CR> ↩︎

See Also

» Vim and clangd » Jupyter kernels in Neovim » No more VS Code » Texing in Vim » Org in Vim