Vim tip 32: text and indent settings
Here are some text and indent Vim settings that you can put in the vimrc
file to customize your editor. See :h options.txt for complete reference.
- filetype plugin indent on enables loading of
plugin
andindent
files- these files become active based on the type of the file to influence syntax highlighting, indentation, etc
- :echo $VIMRUNTIME gives your installation directory (
indent
andplugin
directories would be present in this path) - see :h vimrc-filetype, :h :filetype-overview and :h filetype.txt for more details
- set autoindent copy indent from the current line when starting a new line
- useful for files not affected by
indent
setting - see also :h smartindent
- useful for files not affected by
- set textwidth=80 guideline for Vim to automatically move to a new line with
80
characters as the limit- white space is used to break lines, so a line can still be greater than the limit if there's no white space
- default is
0
which disables this setting
- set colorcolumn=80 create a highlighted vertical bar at column number
80
- use
highlight ColorColumn
setting to customize the color for this vertical bar - see vi.stackexchange: Keeping lines to less than 80 characters for more details
- use
- set shiftwidth=4 number of spaces to use for indentation (default is
8
) - set tabstop=4 width for the tab character (default is
8
) - set expandtab use spaces for tab expansion
- set cursorline highlight the line containing the cursor
Video demo:
See also my Vim Reference Guide and curated list of resources for Vim.