Vim is a highly configurable editor, and if you can’t configure something as you want, plugins are available. While this post won’t cover plugins, it will cover the most useful options you can set in Vim. This is meant for beginner users of Vim; advanced users probably know all of the following already.
To make options permanent, you can modify your ~/.vimrc
file. Type vim ~/.vimrc
, type in the commands (one per line) and save.
Line numbers
Showing line numbers in a paragraph to the left can prove useful when programming. To do so, use :set number
. If you want to disable that, just type :set nonumber
.
Highlight search results
To enable highlighting of search results, type :set hlsearch
, and to disable, type :set nohlsearch
.
Auto- and smartindent
Autoindent will put you at the same indention as the previous line when opening a new line below. To enable autoindent, use :set autoindent
, and to disable it, use :set noautoindent
.
Smartindent is more advanced, and will try to guess the right indention level in C-like languages (only). To enable smartindent, type :set smartindent
, and to disable it, type :set nosmartindent
.
Change colorscheme
Use the :colorscheme {name}
command to set the active colorscheme for Vim to {name}
.
Adjust colors for dark or bright backgrounds
If you have trouble reading text as it is too dark on your dark terminal background, you might want to use the :set background=dark
option.
Result of :set background=dark
:
Result of :set background=light
, and also Vim’s default:
To set colors for a bright background, use :set background=light
.
Enable incremental search
To enable incremental search, type :set incsearch
. With incremental search enabled, Vim will find results as you type.
Incremental search can be disabled with :set noincsearch
.
Ignore case in searches
If you want to ignore case in searches (e.g. be able to search for vim
and find Vim
, VIM
and other variations), you can use :set ignorecase
. To start treating letters with different case as different letters again, type :set noignorecase
.
Enable spell checker
To enable Vim’s spell checker, type :set spell
. For help on the commands to use with the spell checker, type :help spell
. You can disable the spell checker with :set nospell
.
The spell checker doesn’t check spelling in code, just comments and non-code files.
Comments (161)