Vim tips and tricks

Image of Author
March 18, 2022 (last updated September 11, 2023)

General Purpose Cheatsheets

Commands I forget a lot

  • :set [setting-name]? to view the current setting value.
  • :echo &rtp to view the runtime path of files that vim checks when running functions. :help rtp for more.
  • when you want to reload .vimrc without leaving vim, execute :source ~/.vimrc

Movement commands

  • ( and ) move to the next sentence
  • { and } move to the next paragraph

Folding

  • za toggle single-fold open or closed
  • zc single-fold close
  • zo single-fold open
  • zM fold everything
  • zR open everything

Autoload directory

The autoload directory will reactively load files as you need them, as opposed to some otherwise upfront load that could result in a slow startup. This is especially relevant for larger libraries, or for when you have many libraries. I understand it as lazy loading, essentially. I.e., load the file only when you are literally about to execute a function from within it.