How do I prevent vim from replacing spaces with tabs when autoindent is on?
An example: if I have two tabs and 7 spaces in the beginning of the line, and tabstop=3
all I want is the autoindented line to have exactly the same indentation characters as the previous line.
'copyindent' 'ci' boolean (default off); local to buffer; {not in Vi}
Copy the structure of the existing lines indent when autoindenting a new line. Normally the new indent is reconstructed by a series of tabs followed by spaces as required (unless 'expandtab' is enabled, in which case only spaces are used). Enabling this option makes the new line copy whatever characters were used for indenting on the existing line. If the new indent is greater than on the existing line, the remaining space is filled in the normal manner.
NOTE: 'copyindent' is reset when 'compatible' is set.
Also see 'preserveindent'.
'preserveindent' 'pi' boolean (default off); local to buffer; {not in Vi}
When changing the indent of the current line, preserve as much of the indent structure as possible. Normally the indent is replaced by a series of tabs followed by spaces as required (unless 'expandtab' is enabled, in which case only spaces are used). Enabling this option means the indent will preserve as many existing characters as possible for indenting, and only add additional tabs or spaces as required.
NOTE: When using ">>" multiple times the resulting indent is a mix of tabs and spaces. You might not like this.
NOTE: 'preserveindent' is reset when 'compatible' is set.
Also see 'copyindent'.
Use :retab to clean up white space.