How do I auto-complete words in insert mode without any plugins?
<C-n> / <C-p>
Vim has a powerful built-in completion system that requires zero plugins.
162 results for "{n}G"
<C-n> / <C-p>
Vim has a powerful built-in completion system that requires zero plugins.
: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
/\%d{decimal}
Vim's regex engine supports special atoms that match characters by their numeric value rather than their glyph.
:let @a = substitute(@a, 'old', 'new', 'g')
After recording a macro or yanking text into a named register, you may need to tweak it — fix a typo in a recorded macro, change a variable name in yanked tex
: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
:set shortmess-=S
The shortmess option controls which messages are shortened.
:%s/pattern//gn
The :%s/pattern//gn command counts how many times a pattern appears in the file without making any changes.
:s/pattern/replace/flags
The substitute command supports several flags that modify its behavior.
cgn
The cgn command combines the change operator with the gn motion to change the next occurrence of your last search pattern.
* then :%s//new/g
Pressing searches for the word under the cursor, which also loads it into the search register.
:.+1,.+3d
Vim's Ex command addresses support arithmetic offsets relative to the current line (.
command-line #ex-commands #editing #navigation #command-line
:%s/pattern/replacement/gn
When you are about to run a broad substitution, it is often safer to measure impact first.
command-line #command-line #ex-commands #substitution #search
: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.
vim.keymap.del()
vim.
/\%>5c\%<20cpattern
How it works Vim's search patterns support column position constraints using the \%c family of atoms.
qq;.q then @q or @@
The dot command (.
winrestcmd()
The winrestcmd() function returns a string of Ex commands that, when executed, restore all window sizes to their state at the time of the call.
: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 -.
:echo @/
The / register holds the most recent search pattern.