How do I uppercase only the characters inside a visual selection with :substitute?
:'<,'>s/\%V./\U&/g
When you need to transform text in-place without touching surrounding content, \%V is one of Vim's most precise tools.
:'<,'>s/\%V./\U&/g
When you need to transform text in-place without touching surrounding content, \%V is one of Vim's most precise tools.
:'<,'>s/^/\=line('.')-line("'<")+1 . '. '/
When you need quick numbered steps, logs, or checklist entries, this pattern adds numbers only to the lines you selected, not the whole buffer.
:'<,'>normal @@
When you already have a useful macro but need to apply it to a specific block of lines, :'normal @@ is a high-leverage pattern.
:'<,'>sort /\%V.*$/
When you need to sort records by a substring that starts at a visual column, Vim can do it without external tools.
visual-mode #visual-mode #sorting #ex-commands #text-processing
g<C-g> (visual mode)
In visual mode, pressing g reports detailed statistics for the selected text only — word count, character count, and byte count.
:s/\%Vfoo/bar/
The \%V atom in Vim's regex engine matches only within the area of the last visual selection.
search #search #visual-mode #substitute #advanced #ex-commands
:'<,'>normal {command}
After making a visual selection, :'normal {command} runs any normal-mode command on each selected line individually.
:<C-u>MyCommand<CR>
When writing nnoremap or vnoremap mappings that call Ex commands, Vim may silently prepend a count or a visual range (') to your command before it runs.
mode()
The mode() function returns a short string identifying the current editing mode — 'n' for Normal, 'i' for Insert, 'v' for Visual character-wise, 'V' for Visua
macros #macros #normal-mode #visual-mode #insert-mode #editing
v2ap
In Vim, text objects accept a count prefix in visual mode, letting you select multiple consecutive text objects in one keystroke.
<Cmd>
The pseudo-key in Neovim allows a mapping to execute an Ex command directly, without going through command-line mode.
matchadd()
The matchadd() function adds a persistent highlight for a pattern in the current window without touching your search register or interfering with n/N navigation
:'<,'>w !{cmd}
The :'w !{cmd} command writes the visually selected lines to the stdin of an external shell command — without modifying the buffer.
gh
Vim's Select mode behaves like the familiar selection model in most GUI editors: after selecting text, any printable character you type replaces the selection a
:'<,'>w {filename}
After making a visual selection, you can write only those lines to a new file using :'w {filename}.
:set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr:hor20
Neovim's guicursor option lets you assign a distinct cursor shape and style to each mode, providing immediate visual feedback about which mode you are in.
:'<,'>right {width}
The :right Ex command right-aligns lines within a given column width by padding them with spaces on the left.
visual-mode #visual-mode #formatting #ex-commands #alignment
autocmd TextYankPost
The TextYankPost event fires immediately after any yank operation completes — including y, Y, dd, dw, and any other command that writes to a register.
:'<,'>sort!
The sort! command sorts the selected lines in reverse (descending) order.
:set showcmd
The showcmd option makes Vim display the currently-typed command in the bottom-right corner of the screen, giving you live feedback as you build up key sequence