Hidden gems inside your VIM Distribution

Have you ever looked into what comes with your VIM distribution?
To do so just :echo $VIMRUNTIME inside VIM and open that directory in your terminal.

Games and strange stuff

The $VIMRUNTIME directory holds a macros directory which contains useful and some strange stuff.

  • A recent version of matchit.vim is available here.
    No need to use an external version just runtime macros/matchit.vim inside your .vimrc
  • There's a Conway's Game Of Life implementation available:
    Start vim, then :runtime macros/life/life.vim and press g
  • Tower of Hanoi anyone?
    :runtime macros/hanoi/hanoi.vim and again press g
  • Maze solver. A little more involving to make it run:
    Open terminal and go to your $VIMRUNTIME
    cd macros/maze && make && ./maze > maze.out
    input 30 and press enter
    vim maze.out then :runtime macros/maze/maze_mac then g
  • Menu in gvim for a lot of shell functions:
    :runtime macros/shellmenu.vim
  • Text justification via :runtime macros/justify.vim then :Justify

Working with Git

VIM contains a filetype plugin for git commits (made by Tim Pope).
If you commit with VIM as your editor you can set ft=gitcommit and then use :DiffGitCached to generate a diff with your changes.

Also availabe is a useful plugin for handling interactive rebases with git. Insert the following into your .vimrc:

augroup vim_config
  autocmd FileType gitrebase call LoadGitrebaseBindings()
augroup END

fun! LoadGitrebaseBindings() nnoremap P :Pick nnoremap S :Squash nnoremap C :Cycle endfun

If you git rebase -i you can then use P, S or C to Pick, Squash or Cycle through the available options.

Have fun,

Mehr? Aktuelle Artikel oder alle Artikel im Archiv.