Home   Profile   Fun
#150 Linux  07.01.2008

How to paste text into VIM with correct text indention


In the standard configuration VIM uses auto indention for pasted text. This auto indention has a strange behaviour and is almost always not what is wanted. If you paste several lines into VIM which contain only lines that start with characters or empty lines everything is fine. But as soon as one of the lines start with whitespaces the indention is not being removed again in the following lines and thus increases more and more.

To avoid this temporarily within VIM type
:set noautoindent
:set nocompatible

Or for a permanent setting open ~/.vimrc and add this line:
set noautoindent
set nocompatible

Accordingly you can activate it again with
set autoindent
set compatible