How do I change the filetype of the current buffer to get correct syntax highlighting and indent rules?
:setfiletype {filetype}
:setfiletype {filetype} sets the filetype option for the current buffer only if it has not already been set.
:setfiletype {filetype}
:setfiletype {filetype} sets the filetype option for the current buffer only if it has not already been set.
:set formatprg=<cmd>
When formatprg is set, the gq operator pipes the selected text through that external program and replaces it with the program's output.
:set {option}&
Append & to any :set command to reset that option to its compiled-in default value — the value Vim shipped with before any vimrc or plugin changed it.
:set wildmode=list:longest
Vim's wildmode option controls how the command line behaves when you press to complete filenames, buffer names, or Ex commands.
zG
zG marks the word under the cursor as correctly spelled in Vim's internal word list, which exists only for the current session.
:set exrc secure
Adding set exrc to your vimrc tells Vim to read a .
:2match Todo /FIXME/
Vim provides three independent match slots — :match, :2match, and :3match — each of which highlights a pattern using a specified highlight group.
:set foldmethod=expr
Setting foldmethod=expr tells Vim to call the foldexpr expression for every line to compute its fold level.
:set foldtext={expr}
The foldtext option controls what Vim displays for a closed fold.
vim.opt.option:append(value)
Neovim's vim.
:set wildcharm=<Tab>
The wildcharm option designates a key that, when it appears inside a mapping, triggers wildmenu completion on the command line — just as if you had pressed in
:iabbrev {lhs} {rhs}
The :iabbrev command defines insert-mode abbreviations — short character sequences that automatically expand into longer text when you type a non-keyword char
:let $VAR = "value"
Vim lets you read and write environment variables using the $VARIABLE syntax in Vimscript.
:set path+=** | :find
By adding to Vim's path option and using :find, you can search for any file recursively through your project tree with tab completion — no plugins required.
:set grepprg={cmd} grepformat={fmt}
Vim's :grep command delegates to an external tool defined by grepprg, then parses the output according to grepformat to populate the quickfix list.
:set foldopen
The foldopen option lets you specify exactly which cursor movements and commands will automatically open a closed fold.
:set display=lastline
By default, when the last visible line of a window is too long to fit on screen, Vim shows @@@ in its place — hiding the content entirely.
autocmd ++once
The ++once flag, added in Vim 8.
:set formatprg={program}
Vim's gq operator normally reflows text to fit textwidth, but by setting formatprg you can delegate formatting to any external tool — a language formatter, a
:trust
Neovim supports project-local configuration via a .