How do I search forward but place the cursor at the end of the match?
/TODO/e
Most users know /pattern, but fewer use search offsets to control where the cursor lands after the match.
415 results for "n N"
/TODO/e
Most users know /pattern, but fewer use search offsets to control where the cursor lands after the match.
:tabmove +1
:tabmove normally takes an absolute position (:tabmove 0 moves the tab to the far left), but it also accepts relative offsets using + and -.
/pattern/e
Search offsets let you place the cursor at a specific position relative to the match.
:keeppattern s/old/new/g
When you run a :s or :g command, Vim updates the search register (@/) with the pattern you used.
G
The G command moves the cursor to the last line of the file.
:keeppatterns {command}
The :keeppatterns modifier runs an Ex command — typically :s, :g, or :v — without modifying @/ (the last search pattern) or the command history.
command-line #ex-commands #search #substitution #command-line #scripting
]q
The vim-unimpaired plugin (by Tim Pope) provides a consistent [x / ]x mnemonic for navigating any list-like structure in Vim.
:%s/pattern//gn
The :%s/pattern//gn command counts how many times a pattern appears in the file without making any changes.
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
:.+1,.+3d
Vim's Ex command addresses support arithmetic offsets relative to the current line (.
command-line #ex-commands #editing #navigation #command-line
l (in :%s///gc confirm prompt)
When running an interactive substitution with the c flag (e.
editing #search #editing #substitution #ex-commands #normal-mode
:terminal
The :terminal command opens an interactive terminal emulator directly inside a Vim window.
setreg()
The setreg(reg, value, type) and getreg(reg, 1, 1) functions give you full programmatic control over registers, including their type (characterwise, linewise, o
vim.diagnostic.jump()
Neovim 0.
gn
The gn motion searches forward for the next match of the last search pattern and visually selects it.
search #navigation #search #motions #normal-mode #repeat #editing
*
The command searches forward for the exact word under the cursor, jumping to the next occurrence.
:ls
The :ls command displays a list of all open buffers in Vim, showing their buffer number, status indicators, file name, and the line the cursor was last on.
* (in visual mode)
In normal mode, searches for the word under the cursor with word-boundary anchors.
:chistory
Every time you run :grep, :vimgrep, :make, or :cexpr, Vim creates a new quickfix list and pushes the previous one onto a history stack.
buffers-windows #buffers-windows #quickfix #navigation #ex-commands
:set completeopt=menuone,noselect
By default, Vim's and completion can auto-insert the first match, or only show a menu when there are multiple matches.