Multiple choice technology operating systems

How to specify the indent width of the text in vi editor

  1. :set sw=4

  2. :set aw=4

  3. :set iw=4

  4. :set ai

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

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).

AI explanation

: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.