How to specify the indent width of the text in vi editor
-
:set sw=4
-
:set aw=4
-
:set iw=4
-
:set ai
In vi editor, 'sw' stands for 'shiftwidth' which controls the indentation width for auto-indent operations. The command ':set sw=4' sets the indent width to 4 spaces. Options B, C, and D are either incorrect options or control different settings (aw controls auto-write, ai controls auto-indent enabling, iw doesn't exist as a standard option).
:set sw=4 is correct. In vi/vim, sw is the shiftwidth option, which controls how many columns text is indented/outdented when using indent commands (like >>, <<) or when autoindent shifts a line — setting it to 4 makes each indent level 4 spaces wide. :set aw=4 is invalid syntax dressed up to look plausible ('aw' is actually the boolean autowrite option, which doesn't take a numeric width). :set iw=4 isn't a real vi option. :set ai just toggles autoindent on/off (carries over the previous line's indent) — it has no numeric width parameter, so it doesn't control indent size the way the question asks.