Vim Examples: Configuration and the vimrc file

Last updated:

WIP Alert This is a work in progress. Current information is correct but more content may be added in the future.

Show line numbers

:set number in NORMAL MODE or add set number to your .vimrc file

Use spaces for tabs

  • expandtab causes vim to write spaces (instead of a '\t' character) when you hit the key on your keyboard.

  • tabstop controls how many columns will an existing '\t' character take

  • softtabstop controls how many columns will an added '\t' character take (only if you don't enable expandtab)

  • shiftwidth controls how many columns to use for automatic indenting.

In my opinion (I write mostly Scala, Python and shell code), the most useful configuration uses spaces for tabs, and tabs are 4 columns wide:

:set softtabstop=4 shiftwidth=4 expandtab

Alternatively, put these into your .vimrc file:

set softtabstop=4
set shiftwidth=4 
set expandtab

Language-specific configuration


Enable backspace in insert mode

set backspace=indent,eol,start


Dialogue & Discussion