How do I make Vim sort buffer completions by most recently used?
set wildmode=lastused
With wildmode=lastused, :b cycles buffers in most-recently-used order instead of alphabetically.
set wildmode=lastused
With wildmode=lastused, :b cycles buffers in most-recently-used order instead of alphabetically.
set wildcharm= then nnoremap b :b
wildcharm sets the key that triggers wildmenu expansion inside mappings.
:match {group} /{pattern}/
:match lets you apply a highlight group to any pattern in the current window without touching the buffer or its syntax rules.
:set nrformats+=alpha
By default, and only increment and decrement numbers (decimal, hex, and octal depending on format).
iabbrev
:iabbrev defines insert-mode abbreviations that expand automatically when you type a non-keyword character (space, punctuation, ) after the abbreviation.
:set opfunc and g@
Vim's operatorfunc option lets you define your own operators — just like the built-in d, y, or c — that accept any motion or text object.
zx
The zx command resets and recomputes all folds in the current window based on the current foldmethod.
]s / [s / z=
Vim has a built-in spell checker that highlights misspelled words and provides correction suggestions — all without plugins.
:set iskeyword+=-
By default, Vim treats hyphens, dots, and many punctuation characters as word boundaries.
:set matchpairs+=<:>
By default, the % command jumps between (), {}, and [] pairs.
config #navigation #config #matchpairs #editing #normal-mode
:profile
When Vim feels sluggish to start, the built-in :profile command lets you measure exactly how much time each script, function, or plugin takes to load.
:breakadd func {funcname}
Vim has a built-in debugger for Vimscript that most users never discover.
:setlocal statusline=%f\ %m\ %y\ [%l/%L]
The :setlocal statusline command lets you override the global statusline for a specific window.
:set diffopt+=iwhite
When comparing files in Vim's diff mode, whitespace-only changes (extra spaces, changed indentation) can clutter the diff and hide meaningful edits.
:nnoremap <expr> j (v:count == 0 ? 'gj' : 'j')
Expression mappings use the flag to evaluate a Vimscript expression at the time the key is pressed.
:set wildmenu wildmode=longest:full,full
By default, Vim's command-line tab completion just cycles through options.
:profile start profile.log
When Vim feels sluggish, the built-in :profile command lets you measure exactly how much time each script and function consumes.
autocmd FileType python setlocal ts=4 sw=4 et
Using autocmd FileType, you can configure Vim to automatically apply buffer-local settings whenever a file of a particular type is opened.
:syntax sync fromstart
Vim's syntax highlighting engine does not always parse the entire file from the beginning — it uses sync points to determine where to start parsing for the vi
:set operatorfunc=MyFunc<CR>g@
Vim lets you define custom operators that behave like built-in ones (d, c, y) — they wait for a motion or text object, then act on the selected region.