How do I sort lines and remove duplicates in Vim?
:%sort u
The :sort u command sorts all lines in the file and removes duplicate lines in one operation.
command-line #command-line #ex-commands #editing #text-manipulation #sort
795 results for "G"
:%sort u
The :sort u command sorts all lines in the file and removes duplicate lines in one operation.
command-line #command-line #ex-commands #editing #text-manipulation #sort
:<C-f>
Long Ex commands are easy to mistype when you edit inline on a single command line.
:cdo keeppatterns s/\<foo\>/bar/gec | update
When quickfix already contains precise targets, :cdo gives you a safer multi-file replace loop than broad project substitutions.
command-line #command-line #quickfix #substitute #refactoring
/\%>10l\%<20lpattern
Vim's \%>Nl and \%10l matches only after line 10 \%10l\%10l\%<20lold/new/g Combine with column restrictions for precise region targeting Tips Line numbers in \%
:wall
When working across multiple files, you often have unsaved changes in several buffers.
crs / crc / crm / cru
The vim-abolish plugin adds coercion operators that instantly convert the word under the cursor between common naming conventions.
plugins #editing #text-objects #plugins #normal-mode #formatting
vim-polyglot
The vim-polyglot plugin is a curated collection of language packs for Vim that provides syntax highlighting, indentation, filetype detection, and compiler suppo
/\Cpattern
Vim's ignorecase and smartcase settings change how all searches behave globally.
:%s/pattern/replacement/ge
The e flag on :substitute silences the "Pattern not found" error that Vim normally reports when a substitution has no matches.
:set shortmess+=I
The shortmess option is a string of single-character flags that tell Vim which messages to suppress or abbreviate.
:%d
The % range address in Ex commands stands for the entire file — it is shorthand for 1,$ (first line to last line).
:reg {name}
The :reg {name} command displays the current contents of one or more named registers in a formatted listing.
<C-w>d
Neovim 0.
buffers-windows #diagnostics #lsp #floating-window #neovim #buffers #windows
ga
The ga command displays the ASCII/Unicode value of the character under the cursor in decimal, hexadecimal, and octal.
editing #editing #unicode #debugging #normal-mode #inspection
<C-a> (in insert mode)
While in insert mode, pressing re-inserts whatever text you typed during your previous insert session.
/\%V
The \%V pattern atom restricts a search to the region spanned by the last visual selection.
:cexpr system('rg --vimgrep "TODO"')
When you already know you want an external search tool, :cexpr lets you import results directly into quickfix without opening a terminal buffer or shelling out
:vimgrep /\<TODO\>/gj **/*.lua | copen
When you want a project-wide TODO pass without leaving Vim, :vimgrep plus quickfix is a strong built-in workflow.
search #search #quickfix #command-line #project-navigation #ex-commands
/\(pattern\)\@<=target or /target\(pattern\)\@=
Vim supports zero-width assertions (lookahead and lookbehind) in its regex engine.
/foo\|bar
How it works The \ operator in Vim's search pattern works like a logical OR, letting you match any one of several alternatives.