Skip to main content

Vim

The best text editing experience you will ever get. It is worth learning it as you will start thinking about text editing differently.

I use some kind of vim bindings in any app I use and if there is a vim plugin for the app, I often use it. I use vim editor often when connecting to remote sessions and when I need a console editor.

I use Neovim instead of vim and my vimrc can be found here. And here are all the plugins I use with it.

I switch between Ayu Light and Ayu Mirage themes as I change between macOS appearances.

Ayu Light

Ayu Mirage

I also use a little trick where I change the cursor from thin block in insert mode to underline when in normal mode. This lets me quickly know which mode I am in.

Notes​

  • I can profile vim startup time with startuptime.
  • I can run :CheckHealth to see if there is anything wrong with my installation (only Neovim).
  • Get plugins that meet your needs.
  • You're more likely to find useful plugins if you approach it the other way around: I want to do X, vim can't do it nicely by itself, which plugin can help me do it.
  • If something doesn't work in vimrc, put the binding in the bottom of vimrc (perhaps something overrides it).
  • I care about reducing friction, and Vim's editing language is very good at that.

Code​

" Insert text in the end of each line
" s/ - substitute.
" $ - the end of the line.
" / - change it to.
" , - a comma.
:%s/$/,
" Lowercase line
Vu
" Find char backwards
F<char>
" Delete backwards until char
dT<char>
" Visually select until char
v/<char><return>
" Delete all lines in file
:%d
" Yank two inner words
" Yanks first and second words (with the trailing space) in the unnamed register
y2aw
" Delete until start of line
d0
" Yank entire file
:%y+
" Select entire block
Vat
" Visually select until end of line
v$
" Visually select paragraph or function
V}
" See whats in a buffer
" See insides of q buffer
:echo @q
" See registers
:registers
" Delete until end of file
VGx
" Visually select block
V%
" Start recording macro
" Record to register d
qd
" Delete char under cursor
x
" Yank inside tag. Can yank an XML tag for example
yat
" Make multi line search. https://vim.fandom.com/wiki/Search_across_multiple_lines
" Will carry over to new line
\_s
" Inclusive search
/foo/e
" Delete until searched string. Won't delete string itself.
d/string
" Search and replace
:%s/<search>/<replace>/g
" Run command on startup
" Run ':Goyo' on startup. Put it in .vimrc
autocmd VimEnter * Goyo"
" Insert text at start of each line in file
" Insert // at start of each line in file
:%s!^!//!
" Replay last macro
@@
" Delete until character
df<char>
" Centre current line
zz
" Put results of command into a register
" In normal mode, will put results of d$ command into _ (black hole register)
"_d$
" Run macro on whole file
:%normal @x " will run macro x