How do I match an optional sequence of characters at the end of a word in a Vim regex?
\%[abc]
The \%[.
795 results for "G"
\%[abc]
The \%[.
set showbreak=↪\
When wrap is enabled, long lines visually wrap to the next screen row.
:setglobal
Vim maintains two values for most options: a global default that applies to new windows and buffers, and a local copy that can be overridden per-buffer or per-w
:keepmarks
When Vim executes commands that move or reorder lines — such as :sort, :%!sort, or :s/// across ranges — it automatically adjusts named marks to follow the
/pattern1/;/pattern2/
Vim's search offsets allow chaining two patterns together with a semicolon.
\%V
The \%V atom in a Vim pattern matches only inside the last visual selection.
search #search #visual-mode #substitute #regex #text-objects
:next
When Vim is opened with multiple files (e.
command-line #buffers-windows #ex-commands #navigation #editing
:vimgrep /\V<C-r><C-w>/gj **/*
When you need a project-wide search for the exact word under your cursor, this pattern avoids regex surprises and immediately populates quickfix.
<C-v>I#<Esc>
Vim's Visual Block mode lets you prepend characters (like comment markers) to multiple lines simultaneously.
:e %:r.html
In Vim's command line, % expands to the current buffer's filename.
command-line #ex-commands #command-line #buffers #navigation
getchar()
getchar() blocks and waits for the user to press a key, returning its numeric character code.
:iabbrev <expr> {trigger} {expression}
The flag on :iabbrev turns the right-hand side into a Vimscript expression that is evaluated at expansion time rather than stored as a literal string.
w
The w command moves the cursor forward to the beginning of the next word.
:call setreg('a', @a . 'text', 'l')
How it works Vim provides two functions for advanced register manipulation: setreg() and getreg().
'0
Pressing '0 in normal mode jumps to the exact cursor position in the most recently edited file, even after closing and reopening Vim.
\%(pattern\)
In Vim's regex engine, \( and \) create a capturing group whose contents are stored in \1, \2, etc.
:%s/\V<C-r>//gc
When your last search pattern contains punctuation, slashes, or regex atoms, retyping it inside :substitute is error-prone.
:vimgrep /{pattern}/j **/*
For project-wide searches, :vimgrep is powerful but can feel disruptive if it jumps into files while populating quickfix.
:sp +/{pattern} {file}
The +{cmd} syntax lets you run an Ex command immediately after a file is opened.
\C in search pattern
Adding \C anywhere in a search pattern forces case-sensitive matching for that search, overriding the global ignorecase setting.