Re-indent all lines
-
gg
- go the beginning of the file -
G
- go to the end of the file -
=
- indent
Useful editor settings
-
:set sw=2
- set shift width for auto-indent to 2 spaces -
:set tabstop=2
- set tab size to 2 spaces -
:set expandtab
- replace tabs with spaces -
:colorcolumn=81
- color column 81 -
:set background=dark
- set background color -
:set paste
- disable auto-indent to paste text -
:set list
- show indents and special characters -
:set nolist
- hide indents and special characters -
:set [no]ai
- enable/disable auto-indent
Search and replace
-
s/foo/bar/g
- replace first occurance of foo on each line with bar -
.,$s/foo/bar/g
- replace all occurances of foo with bar
Miscellaneous
-
Ctrl-V <char>
- type special characters
Resources and documentation
-
[Vim beginner’s guide](https://glm.g-truc.net/0.9.9/index.html)