How do I select the text I just pasted or changed?
`[v`]
The ` [v] sequence visually selects the exact region of text that was last changed, pasted, or yanked into the buffer.
visual-mode #editing #visual-mode #marks #paste #productivity
`[v`]
The ` [v] sequence visually selects the exact region of text that was last changed, pasted, or yanked into the buffer.
visual-mode #editing #visual-mode #marks #paste #productivity
:set hidden
By default, Vim refuses to let you switch away from a buffer that has unsaved changes, forcing you to save or discard with :w or :e! before moving on.
<C-o>{cmd}
Pressing in insert mode lets you execute one normal mode command and then automatically returns you to insert mode.
z=
When spell checking is enabled, the z= command opens a numbered list of spelling suggestions for the misspelled word under the cursor.
editing #editing #spell-check #normal-mode #productivity #prose
g*
The g command searches forward for the text under the cursor without adding word boundary anchors.
search #search #navigation #normal-mode #motions #productivity
<C-w>H / <C-w>J / <C-w>K / <C-w>L
The H, J, K, and L commands move the current window to the far left, bottom, top, or right of the screen respectively, rearranging your entire split layout.
buffers-windows #windows #buffers #navigation #splits #layout
qaqqa...@aq
A recursive macro calls itself at the end of its recording, creating a loop that repeats until a motion or command fails (like reaching the end of the file or f
:redir @a | {cmd} | redir END
The :redir command redirects the output of Ex commands to a register, file, or variable instead of displaying it on the screen.
command-line #command-line #ex-commands #registers #productivity #advanced
; / ,
After using f, t, F, or T to jump to a character on the current line, pressing ; repeats the same search in the same direction, and , repeats it in the opposite
navigation #navigation #motions #normal-mode #editing #productivity
@:
The @: command re-executes the most recently run Ex command (any command starting with :).
command-line #command-line #ex-commands #repeat #normal-mode #productivity
&
The & command in normal mode repeats the last :s substitution on the current line.
search #search #substitution #ex-commands #repeat #normal-mode
R
Replace mode lets you type over existing text one character at a time, like the "Insert" key behavior in traditional editors.
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
Vim remembers the last cursor position for every file you edit (stored in the viminfo or shada file), but by default it opens files at line 1.
gi
The gi command moves the cursor to the position where you last exited insert mode and immediately enters insert mode again.
navigation #navigation #insert-mode #marks #normal-mode #productivity
:%s//new/g
Leaving the search field empty in a :s command tells Vim to reuse the last search pattern from / or .
search #search #substitution #ex-commands #regex #productivity
:g/^/m0
The :g/^/m0 command is a clever use of Vim's global command to reverse every line in the file.
:bufdo normal @a
The :bufdo command executes an Ex command in every open buffer, and when combined with :normal @a, it replays macro a across all of them.
macros #macros #buffers #ex-commands #automation #productivity
:g/pattern/normal @a
The :g (global) command combined with :normal @a lets you execute a recorded macro only on lines matching a pattern.
macros #macros #ex-commands #global-command #editing #automation
:mksession / :source Session.vim
Vim's session feature saves a snapshot of your entire workspace — open buffers, window layout, tab pages, current directory, and more — to a file that you c
buffers-windows #buffers #windows #config #productivity #workflow #session
vim: set ts=2 sw=2 :
A modeline is a special comment embedded in a file that Vim reads to apply file-specific settings automatically.