vim

Vim Options

Syntax#

  • :set [no](option|shortcut)
  • :set (option|shortcut)=value
  • :set (option|shortcut)(?|&)
  • do not use : in the vimrc file

Remarks#

See vimcast 1 video

See vimcast 1 transcript

Set

To set the options - use :set instruction. Example:

:set ts=4
:set shiftwidth=4
:set expandtab
:set autoindent

To view the current value of the option - type :set {option}?. Example:

:set ts?

To reset the value of the option to its default - type :set {option}&. Example:

:set ts&

Indentation

Width

To make indentations 4 spaces wide:

:set shiftwidth=4

Spaces

To use spaces as indents, 4 spaces wide:

:set expandtab
:set softtabstop=4

softtabstop and sts are equivalent:

:set sts=4

Tabs

To use tabs as indents, 4 spaces wide:

:set noexpandtab
:set tabstop=4

tabstop and ts are equivalent:

:set ts=4

Automatic Indentation

:set autoindent

Instruction descriptions

Instruction Description Default
tabstop width of tab character 8
expandtab causes spaces to be use instead of tab character off
softabstop tune the whitespace 0
shiftwidth determines whitespace amount when in normal mode 8

Invisible characters

Show or hide invisible characters

To show invisible characters:

:set list 

To hide invisible characters:

:set nolist

To toggle between showing and hiding invisible characters:

:set list!

Default symbol characters

Symbol Character
^I Tab
$ New Line

Customize symbols

To set the tab character to **> ** and the new line character to ¬

set listchars=tab:>\ ,eol:¬

To set the spaces to _

set listchars=spaces

To see a list of character options

:help listchars

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow