Indenting a new line to match prior lines is a vim option autoindent , smartindent or cindent which you can turn off.

*'autoindent'* *'ai'* *'noautoindent'* *'noai'* 'autoindent' 'ai' boolean (default off) local to buffer

Copy indent from current line when starting a new line (typing in Insert mode or when using the "o" or "O" command). If you do not type anything on the new line except or CTRL-D and then type , CTRL-O or , the indent is deleted again. Moving the cursor to another line has the same effect, unless the 'I' flag is included in 'cpoptions'.

When autoindent is on, formatting (with the "gq" command or when you reach 'textwidth' in Insert mode) uses the indentation of the first line.

When 'smartindent' or 'cindent' is on the indent is changed in a different way.

The 'autoindent' option is reset when the 'paste' option is set. {small difference from Vi: After the indent is deleted when typing or , the cursor position when moving up or down is after the deleted indent; Vi puts the cursor somewhere in the deleted indent}.

*'smartindent'* *'si'* *'nosmartindent'* *'nosi'* 'smartindent' 'si' boolean (default off)

local to buffer

{not in Vi}

{not available when compiled without the

|+smartindent| feature}

Do smart autoindenting when starting a new line. Works for C-like programs, but can also be used for other languages. 'cindent' does something like this, works better in most cases, but is more strict, see |C-indenting|. When 'cindent' is on or 'indentexpr' is set, setting 'si' has no effect. 'indentexpr' is a more advanced alternative.

Normally 'autoindent' should also be on when using 'smartindent'. An indent is automatically inserted: - After a line ending in '{'.

- After a line starting with a keyword from 'cinwords'.

- Before a line starting with '}' (only with the "O" command).

When typing '}' as the first character in a new line, that line is given the same indent as the matching '{'.

When typing '#' as the first character in a new line, the indent for that line is removed, the '#' is put in the first column. The indent is restored for the next line. If you don't want this, use this mapping: ":inoremap # X^H#", where ^H is entered with CTRL-V CTRL-H.

When using the ">>" command, lines starting with '#' are not shifted right.

NOTE: 'smartindent' is reset when 'compatible' is set. When 'paste' is set smart indenting is disabled.