How do I create a custom operator that works with any motion in Vim?
:set operatorfunc=MyFunc<CR>g@{motion}
Vim's operatorfunc and g@ let you define custom operators that accept any motion or text object, just like built-in operators d, c, and y.
:set operatorfunc=MyFunc<CR>g@{motion}
Vim's operatorfunc and g@ let you define custom operators that accept any motion or text object, just like built-in operators d, c, and y.
:syntime on
When Vim feels sluggish while editing files with complex syntax highlighting, :syntime lets you profile exactly which syntax rules are consuming the most time.
:set nrformats+=hex,bin
By default, Vim's and only increment and decrement decimal numbers.
vim --startuptime /tmp/vim-startup.log
When Vim takes too long to start, the --startuptime flag writes a detailed timing log showing exactly how long each plugin, script, and initialization step take
:set undofile undodir=~/.vim/undodir
By default, Vim's undo history is lost when you close a file.
:highlight MyGroup guifg=#ff0000 guibg=NONE gui=bold
The :highlight command lets you define custom colors for syntax elements, UI components, and your own highlight groups.
:setlocal iskeyword+=-
The iskeyword option defines which characters are part of a "word" for motions like w, b, e, , and text objects like iw.
vim: set ts=2 sw=2 et:
Modelines are special comments at the top or bottom of a file that Vim reads to apply file-specific settings.
:set path+=**
Adding to the path option tells Vim to search recursively through all subdirectories when using :find, gf, and other path-related commands.
:let &t_SI = "\e[6 q"
Modern terminals support cursor shape changes via escape sequences.
:set formatoptions+=cro
The formatoptions setting controls how Vim automatically formats text as you type — including comment continuation, auto-wrapping, and paragraph formatting.
:set grepprg=rg\ --vimgrep
Vim's :grep command uses an external program to search files and populate the quickfix list.
:set iskeyword+={char}
iskeyword defines which characters are considered word characters in Vim.
:set breakindent
When wrap is enabled, long lines wrap to the next screen row starting at column 1 by default, which makes indented code look messy.
:set pumheight=10
By default, Vim's completion popup menu (the PUM — Pop-Up Menu) can expand to fill the entire screen if there are many candidates.
:set lazyredraw
When Vim runs a macro or an :argdo / :bufdo loop, it redraws the screen after every command by default.
:set linebreak
By default, when wrap is enabled, Vim wraps long lines at the window edge — which can split words in the middle.
autocmd FileType python setlocal expandtab shiftwidth=4
Vim's autocmd FileType lets you apply settings automatically whenever a specific file type is detected.
:options
:options opens a special Vim buffer that lists every available option, grouped by category (appearance, editing, search, etc.
:set exrc
Vim's exrc option tells Vim to look for a .