Index

Table of contents

vim config

load .vimrc from anywhere
:so $MYVIMRC

config files

config file (all vims)
~/.vimrc
~/.vim/.vimrc
config file (gvim only)
~/.gvimrc
include another config file
source [file]
source $HOME/.vim/include.vim
file to configure vim for specific file type
~/.vim/after/ftplugin/[type].vim
~/.vim/after/ftplugin/java.vim
compiler config
~/.vim/compiler/[name].vim
syntax highlighting file
~/.vim/syntax/[name].vim
filetype detection
~/.vim/ftdetect/[name].vim

config settings

general

show all available options
:options
query setting
:set [option]?
toggle boolean setting
:set [option]!
reset setting
:set [option]&
set multiple settings
:set hlsearch number ignorecase
set setting locally to window (for certain options)
:setlocal [option]

specific options

disable plugin for highlighting matching parenthesis
:let loaded_matchparen = 0
disable highlighting matching parenthesis after plugin has been loaded
:NoMatchParen
show line numbers
:set number
show status line even when there is only one file open
:set laststatus=2
case insensitive searching
:set ignorecase
case insensitive unless any caps in query
:set smartcase
highlighting enabled
:syntax on
highlight matches as you type
:set incsearch
highlight search matches
:set hlsearch
turn of search highlighting (current search)
:nohlsearch
turn of search highlighting (permanently)
:set nohlsearch
show incomplete commands in lower right
:set showcmd
show multiple matches on tab completion
:set wildmenu
tabs are [n] spaces
:set tabstop=[n]
indent with [n] spaces per level
:set shiftwidth=[n]
backspace and space wrap line endings (normal mode)
:set whichwrap=b,s
left and right keys wrap line endings (normal mode)
:set whichwrap=<,>
left and right keys wrap line endings (insert mode)
:set whichwrap=[,]
show special characters such astabs, spaces, newlines, etc. (:help listchars)
:set list
display tabs and trailing whitespace with custom characters
:set listchars=tab:>-,trail:-
display angular brackets at the edge of the screen if there is more content
:set listchars=extends:>,precedes:<
wrap long lines
:set wrap
wrap long lines (smart)
:set wrap linebreak
do no wrap long lines
:set nowrap
Scroll before hitting top or bottom of screen, for improved context
set scrolloff=1
scroll only one character at a time to prevent disorientation
:set sidescroll=1
scroll before hitting the edge of the screen for improved context
:set sidescrolloff=10
do not create backup file
:set nobackup
do not create swap files
set noswapfile
don't create un~ files
set noundofile
do not show toolbar (gvim)
:set guioptions-=T
set path to open file as terminal title
:set title
don't auto indent whitespace
filetype indent off
select indentation rule (orderedbasic to advanced)
:set autoindent
:set smartindent
:set cindent
:set indentexpr=GetMyIndent()     use custom function for indenting lines
write files back to disk before running commands
:set autowrite
select colorscheme
:colorscheme torte
open new horizontal splits below open current
:set splitbelow
open new vertical splits on the right side
:set splitright
turn on the filetype plugin, for file extension specific settings
:filetype plugin on
enable disable vi compatible mode (read help first)
:set compatible
:set nocompatible

gvim only

font selector
:set guifont=*
get current font string
:set gfn?
set font
:set guifont=courier
set font and size (gvim linux)
:set guifont=courier\ 16
:set guifont=Ubuntu\ Mono\ 12

custom syntax highlighting

syntax highlighting hello world (highlights numbers)

~/.vim/syntax/[name].vim
syn match mynum '\d\+'
hi def link mynum Constant
~/.vim/ftdetect/[name].vim
au BufRead,BufNewFile *.hashdoc set filetype=[name]

matching input

keywords
syn keyword basicLanguageKeywords PRINT OPEN IF
region
syn region multilinecomment start="/[*]" end="[*]/"
regex
syn match mynum '\d\+'
define token that doesn't match unless referred to
syn match [token1] [regex] contained
syn match [token2] [regex] nextgroup=[token1]
define more than one nextgroup
syn match [token] [regex] nextgroup=[reference1],[reference2]

highlighting types

list all available highlighting types
:hi
common ones
hi def link [token] Constant
hi def link [token] Identifier
hi def link [token] Statement
hi def link [token] Type

hi def link [token] Comment
hi def link [token] PreProc
hi def link [token] Todo
hi def link [token] Special

plugins

show plugins / vim files loaded
:scriptnames
check if a particular plugin is loaded (1) or not (0)
echo exists("[plugin-flag]")