How do I replace the next search match and repeat it easily with dot?
cgn
The cgn command combines the change operator with the gn motion to change the next occurrence of your last search pattern.
181 results for "n N"
cgn
The cgn command combines the change operator with the gn motion to change the next occurrence of your last search pattern.
<C-w>N
When using Vim's built-in :terminal, the buffer is in Terminal-Job mode by default, meaning all keystrokes go to the running shell.
:%s/pattern//gn
The n flag on the substitute command reports the number of matches without performing any substitution.
<C-w>n
n creates a new empty buffer and opens it in a horizontal split above the current window.
<C-\><C-n>
While works to leave insert or visual mode, it does not work in every situation — particularly in terminal mode (:terminal), where is consumed by the running
:tabmove 0
Use :tabmove N to move the current tab after tab N.
:sb {buffer}
The :sb (short for :sbuffer) command opens a buffer that is already loaded in Vim in a new horizontal split window.
:tab sb N
How it works The :tab sb N command opens buffer number N in a brand new tab page.
/\%>5c\%<20cpattern
How it works Vim's search patterns support column position constraints using the \%c family of atoms.
{N}%
The {N}% command jumps the cursor to the line that is N percent of the way through the file.
:'<,'>!sort -t',' -k2 -n
Vim does not have a built-in multi-column sort, but you can leverage the external sort command to sort selected lines by any field.
editing #editing #sorting #ex-commands #external-commands #command-line
:keeppattern %s/old/new/g
When you run a :s or :%s substitute command, Vim updates the search register (@/) with the substitution pattern.
command-line #ex-commands #search #editing #registers #substitute
?pattern
The ?pattern command searches backward through the file for the given pattern, starting from the cursor position and wrapping around to the end of the file if n
:let @/ = 'pattern'
Writing to the @/ register via :let @/ = 'pattern' sets Vim's last-search pattern directly — without performing a search or moving the cursor.
:s/pattern//gn
The :s///gn command counts how many times a pattern appears in the file without actually replacing anything.
command-line #search #ex-commands #substitution #command-line
:set shortmess-=S
The shortmess option controls which messages are shortened.
<C-n>
The vim-visual-multi plugin (formerly vim-multiple-cursors) brings VS Code-style multiple cursor editing to Vim.
plugins #plugins #visual-multi #editing #multiple-cursors #refactoring
:set completeopt=menu,menuone,noselect
The completeopt option controls the behavior of the completion popup menu.
:Telescope live_grep
Telescope's livegrep picker provides real-time regex search across your entire project as you type.
:oldfiles
:oldfiles displays a numbered list of every file Vim has recorded in its viminfo (or shada in Neovim) file.