How do I extract regex capture groups from a string in Vimscript?
matchlist()
matchlist({str}, {pattern}) runs a regex match and returns a list of all captured groups, making it the idiomatic way to extract structured data from strings in
Search Vim Tricks
Searching...matchlist()
matchlist({str}, {pattern}) runs a regex match and returns a list of all captured groups, making it the idiomatic way to extract structured data from strings in
getchar()
getchar() blocks and waits for the user to press a key, returning its numeric character code.
:~
The :~ command repeats the last substitution but uses the current search pattern instead of the original pattern.
:trust
Neovim supports project-local configuration via a .
:set smoothscroll
The smoothscroll option makes scroll commands respect screen rows rather than buffer lines when wrap is enabled.
ZQ
ZQ is the discard-and-quit counterpart to ZZ.
:set nostartofline
By default, many Vim movement commands — gg, G, Ctrl-d, Ctrl-u, Ctrl-f, Ctrl-b, and others — snap the cursor to the first non-blank character of the destina
:set foldcolumn=1
Setting foldcolumn to a non-zero value adds a narrow column on the left side of each window that visually represents the fold structure of your file.
:tabfind {name}
:tabfind is the tab-aware counterpart to :find.
8g8
The 8g8 command searches forward from the cursor for the first byte that belongs to an invalid UTF-8 sequence.
% (in netrw)
Vim's built-in file explorer netrw (opened with :Explore or :Ex) is more capable than it looks.
{count}J
The J command joins the current line with the line below, adding a space between them.
:let g:netrw_liststyle=3
Vim ships with a built-in file browser called netrw, opened with :Explore (or :Ex).
:set nrformats+=bin
Vim's and commands increment and decrement numbers under the cursor, but by default they only handle decimal and hexadecimal.
autocmd BufWinLeave * mkview
By default, Vim forgets your folds, cursor position, and scroll state every time you close a file.
:set number relativenumber
Enabling both number and relativenumber simultaneously activates hybrid line numbering: the current line displays its true absolute line number while every othe
:set winfixwidth
Setting winfixwidth on a window tells Vim not to adjust its width when other windows are created, closed, or resized with =.
<C-f> (in command line)
Pressing while you are already typing in the Vim command line (:), search line (/ or ?), or input prompt switches you into the command-line window with the curr
command-line #command-line #ex-commands #editing #normal-mode
zfap
Combining the fold-creation operator zf with the ap (around paragraph) text object gives you a quick way to collapse any paragraph into a single fold line.
:keepjumps {command}
The :keepjumps modifier lets you run any movement or command without recording a new entry in the jump list.
navigation #navigation #ex-commands #jump-list #normal-mode #vimscript