How do I quickly create an Ex command range spanning the next N lines using a count before the colon?
Typing a count before : in normal mode automatically fills in a line range in the command line.
category:
command-line
tags:
#command-line
#ex-commands
#ranges
#normal-mode
How do I jump to the start or end of the last visual selection?
The ` ` marks automatically track the boundaries of the last visual selection.
category:
navigation
tags:
#navigation
#marks
#visual-mode
How do I save only a range of lines to a file?
The :w command with a range and filename saves only the specified lines to a new file.
category:
command-line
tags:
#command-line
#ex-commands
How do I use Neovim's built-in lazy iterator API to chain filter and map operations over a list?
vim.
category:
config
tags:
#ex-commands
How do I automatically open or close the quickfix window based on results?
The :cwindow command intelligently manages the quickfix window — it opens the window only if there are entries in the quickfix list, and closes it if the list
category:
command-line
tags:
#command-line
#quickfix
#workflow
#automation
How do I copy a line to another location without yanking?
The :t (copy/transfer) command duplicates the current line and places it after the specified line number.
category:
editing
tags:
#editing
#ex-commands
How do I run a command on lines near each match, not just the matching line itself?
The :g (global) command normally operates on lines that match a pattern.
category:
command-line
tags:
#ex-commands
#editing
#search
#global
How do I move the cursor to the other end of a visual selection?
While in visual mode, pressing o swaps the cursor to the opposite end of the selection.
category:
visual-mode
tags:
#visual-mode
#selection
#cursor
#navigation
How do I move all lines matching a pattern to the top or bottom of a file?
The :global command combined with :move lets you restructure a file by relocating all lines that match a pattern.
category:
editing
tags:
#ex-commands
#editing
#text-objects
How do I run a normal mode command on every line in a range?
The :normal command executes normal mode commands programmatically on a range of lines.
category:
editing
tags:
#editing
#ex-commands
How do I jump back to where I was before my last search?
The double backtick jumps to the exact position before the last jump.
category:
navigation
tags:
#navigation
#marks
#normal-mode
How do I undo all changes made by a macro?
u after macro (single undo)
When a macro makes multiple changes, a single u undoes the entire macro as one unit.
category:
macros
tags:
#macros
#undo-redo
How do I reverse the order of lines in a file or selection?
Vim doesn't have a built-in reverse command, but you can pipe the buffer through tac (reverse of cat) to flip line order.
category:
editing
tags:
#editing
#reverse
#lines
#external-command
How do I return to my previous position after jumping to a tag?
The command pops the tag stack and returns to the position from which you last used or :tag.
category:
navigation
tags:
#navigation
#ex-commands
#normal-mode
How do I move a line to a specific line number?
The :m (move) command moves the current line to after the specified line number.
category:
editing
tags:
#editing
#ex-commands
How do I cycle through my jump history in Vim?
Vim maintains a jump list of positions you have visited.
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I jump back to my previous cursor position?
The (Ctrl+o) command jumps the cursor backward through the jump list, returning you to previous cursor positions.
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I delete all lines matching a pattern?
The :g/pattern/d command deletes every line in the file that matches the given pattern.
category:
command-line
tags:
#search
#ex-commands
#editing
#command-line
How do I undo or redo to a specific point in time using time-based undo navigation?
: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.
category:
command-line
tags:
#undo-redo
#ex-commands
#editing
How do you record a macro to format phone numbers with dashes?
qa0f lll i-<Esc>llli-<Esc>jq
Record a macro that positions the cursor in a 10-digit number and inserts dashes at positions 3 and 6 to create the format xxx-xxx-xxxx.
category:
macros
tags:
#macros
#format
#phone