How do I set a bookmark that takes me back to a specific line in any file?
mA
Uppercase marks (A–Z) are global marks in Vim — they persist across files and even across sessions (when viminfo or shada is configured).
Search Vim Tricks
Searching...mA
Uppercase marks (A–Z) are global marks in Vim — they persist across files and even across sessions (when viminfo or shada is configured).
%:p:h
Vim's filename modifiers let you derive path components from the current file's name directly inside ex commands.
:set equalprg=gofmt
By default, Vim's = operator re-indents text using its internal rules.
config #config #editing #ex-commands #formatting #indentation
[i
Pressing [i in normal mode displays the first line above the cursor (including included files) that contains the keyword under the cursor.
:s/\v\w+/\U&/g
Vim's substitute command supports special case-conversion sequences in the replacement string, letting you transform matched text to upper or lower case without
!{motion}{cmd}<CR>
In normal mode, !{motion} sends the lines covered by the motion to a shell command's stdin and replaces them with stdout.
:filter /pattern/ {command}
:filter /pattern/ {command} runs any Ex command but suppresses every output line that does not match the pattern.
qq{actions}@qq
A recursive macro ends by calling itself, so it loops automatically without you pressing @q repeatedly.
:set splitright splitbelow
By default, :split opens a new window above the current one and :vsplit opens to the left — the opposite of most modern IDEs and editors.
V%
Pressing V% enters visual line mode on the current line and immediately extends the selection to the line containing the matching bracket or brace.
gcip
The vim-commentary plugin exposes gc as a comment operator, which means it composes with any Vim motion or text object.
plugins #plugins #editing #commenting #text-objects #normal-mode
yss"
The yss{char} mapping from the vim-surround plugin surrounds the entire current line (ignoring leading whitespace) with the chosen delimiter.
:clearjumps
The :clearjumps command wipes the jump list for the current window, giving you a clean slate for and navigation.
<C-r>-
In insert mode, - pastes the contents of the small delete register ("-).
:sort n
:sort n sorts lines by the first number found on each line, comparing values numerically rather than as strings.
set sidescrolloff
set sidescrolloff={n} keeps at least n columns of context to the left and right of the cursor when long lines cause the view to scroll horizontally.
:helpgrep
:helpgrep {pattern} searches all installed Vim help files for a pattern and populates the quickfix list with every match.
+
The + command moves the cursor to the first non-blank character of the next line.
:Subvert
The vim-abolish plugin's :Subvert command (abbreviated :S) substitutes a word across all its case variants simultaneously.
@q (inside macro recording)
A recursive macro calls itself as its last action, causing it to repeat indefinitely until it hits an error (like reaching end of file or failing a search).