Vim Scripting Cheat Sheet
Lam
Posted on May 13, 2021
[Strings] Include guards
if exists('g:loaded_myplugin')
finish
endif
" ...
let g:loaded_myplugin = 1
[Strings] Syntax
syn match :name ":regex" :flags
syn region Comment start="/\*" end="\*/"
syn region String start=+"+ end=+"+ skip=+\\"+
syn cluster :name contains=:n1,:n2,:n3...
flags:
keepend
oneline
nextgroup=
contains=
contained
hi def link markdownH1 htmlH1
[Strings] Region conceal
syn region inBold concealends matchgroup=bTag start="<b>" end="</b>"
hi inBold gui=bold
hi bTag guifg=blue
[Strings] Conceal
set conceallevel=2
syn match newLine "<br>" conceal cchar=}
hi newLine guifg=green
[Strings] Filetype detection
augroup filetypedetect
au! BufNewFile,BufRead *.json setf javascript
augroup END
au Filetype markdown setlocal spell
[Strings] Highlights
hi Comment
term=bold,underline
gui=bold
ctermfg=4
guifg=#80a0ff
[Strings] Arguments
| <buffer>
| only in current buffer |
| <silent>
| no echo |
| <nowait>
| |
Syntax
[Strings] Explanation
[nvixso](nore)map
β β don't recurse
β
β normal, visual, insert,
eX mode, select, operator-pending
[Strings] Mapping commands
nmap
vmap
imap
xmap
nnoremap
vnoremap
inoremap
xnoremap
...
[Strings] Built-ins
has("feature") " :h feature-list
executable("python")
globpath(&rtp, "syntax/c.vim")
exists("$ENV")
exists(":command")
exists("variable")
exists("+option")
exists("g:...")
Mapping
Reference
π πͺ π
π©
Lam
Posted on May 13, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.