Skip to content

VIM🔗

Related =(join(this.related, ", "))
References Best cheatsheet, Cheat cheatsheet

200

Basics🔗

Registers🔗

  • list: :registers
  • "a-z: named registers
  • find lines longer than n characters: /\%>80v.\+

Files, buffers🔗

  • Modeline: VIM settings in file itself

    • for root usually disabled for security
      Example:
    1
    # vim: ft=yaml tw=4 sw=4
    

Remote file editing

1
vim scp://user@host[:port]//path/to/file

also supports sftp, http (read-only), rsync

Commands🔗

Auto-commands🔗

1
2
" execute script after writing file (https://stackoverflow.com/a/4628210/16096134) or use inotify
:autocmd BufWritePost * !run_tests.sh <afile>

Plugins🔗

Plugin managers

Config🔗

Editing🔗

  • YouCompleteMe
    • Needs compilation
      • dependencies: cmake, pythonXX-devel
      • then run ./install.py in the plugin’s directory
  • sideways: move function arguments (and other delimited-by-something items) left and right
  • Programming languages
    • ruby
    • HTML
      • tagalong.vim: Change an HTML(ish) opening tag and take the closing one along as well
  • vim-pandoc: pandoc integration and utilities for vim
  • vim-tabular:
    • article: gist for automatic indentation/tabularisation when typing for example |

Aesthetics, customisation🔗

Color scheme highlight groups
Show highlight group used for code under cursor:

1
:command! SS echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')

Fancy font with fancy icons
Plugin iryanoasis/vim-devicons with patched font as described in iryanoasis/nerd-fonts.
For example font Hack

  • download patched font files (ttf) from repo and copy them to a directory that is checked for fonts, for example ~/.fonts or /usr/share/fonts
  • rebuild font cache fc-cache -f -v