How do I sort lines by a secondary field while ignoring a common leading prefix?
:[range]sort /regex/
The :[range]sort /regex/ command sorts lines while skipping the portion of each line that matches the regex.
:[range]sort /regex/
The :[range]sort /regex/ command sorts lines while skipping the portion of each line that matches the regex.
expand('<cfile>')
The expand('') function returns the filename that Vim sees under the cursor — the same file that gf would open.
command-line #command-line #ex-commands #navigation #editing #motions
vim.system({cmd}, {opts}, callback)
vim.
:[range]g/pattern/command
The :global command accepts an optional line range prefix that restricts which lines it even considers matching.
/pattern/;+3
In Vim's range notation, a semicolon (;) between two addresses makes the second address relative to the line the first address matched, not to the current curso
:g/^./,/^$/join
The :g/^.
command-line #command-line #editing #global #formatting #paragraphs
:args {pattern}
The :args command sets Vim's argument list to all files matching a glob pattern.
:e %:h
The command :e %:h opens netrw (Vim's built-in file browser) in the directory that contains the current file.
command-line #command-line #navigation #buffers #netrw #editing
:noautocmd {cmd}
The :noautocmd (abbreviated :noa) prefix suppresses all autocommand events for the duration of the command that follows it.
:earlier {time} and :later {time}
Vim's :earlier and :later commands let you navigate the undo history by elapsed time rather than by edit count.
:lua {code}
Neovim's :lua command lets you run arbitrary Lua code inline from the command line.
command-line #command-line #lua #neovim #vimscript #advanced
<C-f> (from command-line)
When you are already in the middle of typing a command (after pressing :) and realize you need to compose something complex — a long substitution, a multi-pip
:w ++ff=unix
The ++ff modifier on :w forces the file format used for writing, independently of the buffer's 'fileformat' option.
command-line #ex-commands #formatting #command-line #editing
:cexpr []
After a :grep, :make, or :vimgrep run, the quickfix list fills with results.
command-line #command-line #buffers-windows #quickfix #ex-commands
##
The ## special token expands to the names of all files currently in Vim's argument list.
:sort i
By default, :sort uses byte-value ordering, which places all uppercase letters before lowercase.
:sort /pattern/
The :sort /{pattern}/ command sorts lines by their content after the first match of the pattern.
:cnoreabbrev {lhs} {rhs}
:cnoreabbrev defines a non-recursive command-line abbreviation — like noremap but for Ex commands.
:e ++enc={encoding}
When Vim auto-detects the wrong character encoding — mojibake where é shows as é is a classic symptom — you can reload the current buffer with a specifi
%:t:r
Vim's % special character expands to the current filename and accepts a chain of colon-delimited modifiers.
command-line #command-line #ex-commands #editing #navigation