Saturday, January 28, 2023
Vim Indentation

https://vimdoc.sourceforge.net/htmldoc/options.html

tabstop ‘ts’

Number of spaces that a <Tab> in the file counts for.

Also see |:retab| command, and ‘softtabstop’ option.

Note: Setting ‘tabstop’ to any other value than 8 can make your file appear wrong in many places (e.g., when printing it).

set tabstop=8

shiftwidth ‘sw’

Number of spaces to use for each step of (auto)indent.

Used for |‘cindent’|, |>>|, |<<|, etc.

set shiftwidth=8

softtabstop ‘sts’

Number of spaces that a <Tab> counts for while performing editing operations, like inserting a <Tab> or using <BS>.

It “feels” like s are being inserted, while in fact a mix of spaces and s is used.

This is useful to keep the ‘ts’ setting at its standard value of 8, while being able to edit like it is set to ‘sts’.

However, commands like “x” still work on the actual characters.

When ‘sts’ is zero, this feature is off.

‘softtabstop’ is set to 0 when the ‘paste’ option is set.

See also |ins-expandtab|.

When ‘expandtab’ is not set, the number of spaces is minimized by using s.

The ‘L’ flag in ‘cpoptions’ changes how tabs are used when ‘list’ is set.

NOTE: This option is set to 0 when ‘compatible’ is set.

set softtabstop=0

expandtab ‘et’

In Insert mode: Use the appropriate number of spaces to insert a <Tab>.

Spaces are used in indents with the ’>’ and ’<’ commands and when ‘autoindent’ is on.

To insert a real tab when ‘expandtab’ is on, use CTRL-V<Tab>.

See also |:retab| and |ins-expandtab|.

NOTE: This option is reset when ‘compatible’ is set.

set expandtab