Configuring and using VIM

Vim is an advanced text editor for use on linux. If you have not used it before, you will need one cheat sheet or some vim tips and tricks to find your way around.

When I use Vim I add a few features:

  • show dark text on light background
  • show line numbers
  • show trailing whitespaces
  • use spaces for tabs
  • set tabstop to 2 spaces
  • set shift width to 2 spaces
  • read files as unix files (show windows/dos CRLF endings as ^M)

This is done by creating the file  ~/.vimrc with the following content:

set t_Co=256
highlight Normal ctermfg=black ctermbg=white
set number
match ErrorMsg ‘\s\+$\|\t’
set expandtab
set tabstop=2
set shiftwidth=2
set fileformats=unix

To create the file I use the script

If you have a file loaded into a VIM buffer with windows/dos CRLF endings, it can be converted to unix format by executing the commands, as explained on the Vim Tips Wiki:

:e ++ff=dos
:setlocal ff=unix

Leave a Reply

Your email address will not be published. Required fields are marked *