How do I move the cursor to the other end of a visual selection without restarting it?
o (visual mode)
In visual mode, pressing o swaps the cursor between the two ends of the selection (the anchor and the free end).
o (visual mode)
In visual mode, pressing o swaps the cursor between the two ends of the selection (the anchor and the free end).
'[ and ']
Vim automatically sets two marks whenever you yank, change, delete, or paste text: ` [ ` (backtick-bracket) marks the start of the affected region, and ] ` mark
<C-r><C-r>{register}
In insert mode, {reg} pastes from a register but treats certain bytes as key inputs — so a register containing \n triggers a newline, \x08 triggers backspace,
: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
:wall
When working across multiple files, you often have unsaved changes in several buffers.
:let @q = "dwelp"
Recording macros with q works well for simple sequences, but complex macros with special keys can be hard to get right in one take.
:g/start/,/end/d
The :g (global) command can operate on ranges, not just single lines.
:set iskeyword+=-
By default, Vim treats hyphens, dots, and many punctuation characters as word boundaries.
{count}<C-a> / {count}<C-x>
While increments and decrements a number by 1, you can prefix either with a count to add or subtract a specific amount.
:set matchpairs+=<:>
By default, the % command jumps between (), {}, and [] pairs.
config #navigation #config #matchpairs #editing #normal-mode
:set suffixesadd+=.js,.ts,.jsx,.tsx
The gf (go to file) command opens the file under the cursor, but it fails when the path lacks an extension — common in JavaScript/TypeScript imports like impo
navigation #navigation #config #editing #buffers #file-management
:'<,'>!sort -t',' -k2 -n
Vim does not have a built-in multi-column sort, but you can leverage the external sort command to sort selected lines by any field.
editing #editing #sorting #ex-commands #external-commands #command-line
:set complete+=kspell
Vim's built-in completion ( / ) sources matches from buffers, included files, and tags by default.
:set scrolloff=999
By default, Vim only scrolls the viewport when the cursor reaches the very top or bottom of the screen.
navigation #navigation #scrolling #config #cursor #scrolloff
:vimgrep /pattern/ **/*
While external tools like grep or ripgrep are fast, Vim's built-in :vimgrep has a key advantage: it populates the quickfix list directly, so you can jump betwee
:profile
When Vim feels sluggish to start, the built-in :profile command lets you measure exactly how much time each script, function, or plugin takes to load.
<C-k>
Vim has a built-in digraph system that lets you type special characters using short two-character codes.
:bufdo
When you need to apply the same change to every file you have open in Vim, switching to each buffer manually is tedious and error-prone.
<C-o>zz
When you are typing in insert mode and the cursor drifts near the top or bottom of the screen, you normally have to press , then zz, then i or a to continue edi
:topleft split {file}
By default, Vim places horizontal splits below and vertical splits to the right (controlled by splitbelow and splitright).