Options set in .vimrc
applies to all vim files. You can use modelines to set specific vim options for one file. Modeline option must be set in .vimrc
to take advantage of this option.
set modeline
The modeline should be the first line in the file. You can set it inn multiple ways as shown below.
# vim: set ai et ts=4 sts=4 sw=4 tw=79 cc=80 wrap wb nu sm:
/* vim: set enc=UTF-8 ai et ts=4 sts=4 sw=4 tw=79 cc=80 wrap wb nu sm: */
// vim: set enc=UTF-8 ai et ts=4 sts=4 sw=4 tw=79 cc=80 wrap wb nu sm:
Explanation ๐
enc=UTF-8
Set encoding to UTF-8ai
Auto intendet
Expand tabs with spacests=4
Tab stop set to 8sts=4
Soft tab stopsw=4
Shift width, used by>>
and<<
tw=79
Text widthcc=80
Set colour column, a colour bare at character 80wrap
Wraps text, only affects how the text is displayedwb
Write a backup before saving filesnu
Show line numberssm
Show matching brackets
Links ๐
More information in the Vim documentations under options.