vim for developer

vim command line

  • vim file.c +10: Open file.c directly at line 10 (doesn’t work with vi, only vim)

  • git diff | vim -: View the output of a command in vim (git diff command in this example)


  • :vs: Vertical Split

  • :split: Horizontal Split

  • :%bd: close all buffers


  • Go to a function definition using ctags:

    • Run “:ctags -R” to create an index of symbols (classes, functions, variables)

    • Put the cursor on a symbol: CTRL+[ goes to the symbol defintion


  • Open a file from encoding cp850: :e ++enc=cp850 document.txt


  • gvim configuration files for user vstinner:

    • C:\Users\vstinner\_vimrc: vim configuration, same than ~/.vimrc on Unix

    • C:\Users\vstinner\_gvimrc: gvim configuration, same than ~/.gvimrc on Unix

Create a symbol link for configuration files using python:

Python 3.8.0
>>> import os
>>> os.symlink(r'\vstinner\misc\conf\vimrc', '_vimrc')
>>> os.symlink(r'\vstinner\misc\conf\gvimrc', '_gvimrc')

Create a symbol links:

  • from C:\vstinner\misc\conf\vimrc to C:\Users\vstinner\_vimrc

  • from C:\vstinner\misc\conf\gvimrc to C:\Users\vstinner\_gvimrc