User Tools

Site Tools


vim:config:indentation:indentation_options

VIM - Config - Indentation - Indentation Options

expandtab

expandtab affects what happens when you press the <TAB> key.

  • If expandtab is set, pressing the <TAB> key will always insert softtabstop amount of space characters.
  • Otherwise, the amount of spaces inserted is minimized by using TAB characters.

shiftwidth

shiftwidth affects what happens when you press », « or ==.

  • It also affects how automatic indentation works.

smarttab

smarttab affects how <TAB> key presses are interpreted depending on where the cursor is.

  • If smarttab is on, a <TAB> key inserts indentation according to shiftwidth at the beginning of the line, whereas tabstop and softtabstop are used elsewhere.
  • There is seldom any need to set this option, unless it is necessary to use hard TAB characters in body text or code.

softtabstop

softtabstop affects what happens when you press the <TAB> or <BS> keys.

  • Its default value is the same as the value of tabstop, but when using indentation without hard tabs or mixed indentation, you want to set it to the same value as shiftwidth.
  • If expandtab is unset, and tabstop is different from softtabstop, the <TAB> key will minimize the amount of spaces inserted by using multiples of TAB characters.
    • For instance, if tabstop is 8, and the amount of consecutive space inserted is 20, two TAB characters and four spaces will be used.

tabstop

tabstop changes the width of the TAB character, plain and simple.

NOTE: Considerations:

  • Using a tabstop value other than the default (8 spaces), will result in your file having a different appearance when using tools such as cat (type on Windows), which cannot use a custom width tab character.
    • On the other hand, using hard tabs for indentation, allows others to view your code with the amount of indentation they prefer.
    • Which of these considerations should have priority, is a matter of personal preference (and company policy).

vim/config/indentation/indentation_options.txt · Last modified: 2022/10/08 15:21 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki