How do I open the directory containing the current file in netrw from within Vim?
The command :e %:h opens netrw (Vim's built-in file browser) in the directory that contains the current file.
category:
command-line
tags:
#command-line
#navigation
#buffers
#netrw
#editing
How do I duplicate the current line to the end of the file without yanking or moving the cursor?
The Ex command :.
category:
editing
tags:
#editing
#ex-commands
#copy
#ranges
How do I reuse the replacement text from my last substitution in a new one without retyping it?
In a Vim substitution, using ~ as the replacement string repeats the replacement text from the most recent :s command.
category:
search
tags:
#search
#substitution
#ex-commands
#editing
How do I run a command without triggering any autocommands, such as saving without auto-formatting?
The :noautocmd (abbreviated :noa) prefix suppresses all autocommand events for the duration of the command that follows it.
category:
command-line
tags:
#ex-commands
#config
#editing
How do I mark multiple files in netrw and batch copy or move them to another directory?
Netrw, Vim's built-in file browser, supports a full marking system that lets you select multiple files and then perform bulk copy, move, or delete operations on
category:
buffers-windows
tags:
#buffers-windows
#navigation
#editing
How do I toggle common Vim options like spell, wrap, and number with single keystrokes using vim-unimpaired?
The vim-unimpaired plugin adds a set of paired bracket mappings, including a powerful family of option toggles.
category:
plugins
tags:
#config
#plugins
#editing
How do I create a self-repeating recursive macro that runs until it reaches the end of the file?
A recursive macro calls itself at the end of its recording, causing it to repeat automatically until an error — such as reaching the end of the file — stops
category:
macros
tags:
#macros
#registers
#editing
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 I insert an actual newline in a substitution replacement, and why does backslash-n not work?
In Vim substitutions, \r in the replacement string inserts a line break, creating a new line.
category:
editing
tags:
#editing
#search
#substitute
#newline
#regex
How do I zero-pad or reformat numbers during a substitution using printf in Vim?
:%s/\d\+/\=printf('%03d', submatch(0))/g
Combining Vim's \= expression substitution with the printf() function lets you apply arbitrary formatting to matched text.
category:
search
tags:
#search
#substitution
#ex-commands
#editing
How do I send a visual selection to an external command as input without replacing the selected text?
The :'w !{cmd} command writes the visually selected lines to the stdin of an external shell command — without modifying the buffer.
category:
visual-mode
tags:
#visual-mode
#ex-commands
#editing
#normal-mode
How do I switch from typing a command to the full command-line window so I can edit it with all normal Vim keys?
<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
category:
command-line
tags:
#command-line
#editing
#normal-mode
How do I hard-wrap a paragraph to fit within textwidth without moving my cursor away from it?
The gw operator reformats text to fit within 'textwidth' — identical in effect to gq, but with one key difference: the cursor returns to its original position
category:
editing
tags:
#editing
#formatting
#text-objects
#normal-mode
How do I use a macro to automatically increment a number on each line?
By recording a one-step macro that increments a number and moves down a line, you can bulk-apply across as many lines as needed with a single count.
category:
macros
tags:
#macros
#editing
#normal-mode
How do I use a count with a text object to operate on multiple words, sentences, or paragraphs at once?
Most Vim users know you can put a count before an operator (3dw) or use a text object once (daw).
category:
editing
tags:
#text-objects
#editing
#delete
#normal-mode
#motions
How do I enter a mode where I select text and then typing immediately replaces the selection, like in most graphical editors?
Vim's Select mode behaves like the familiar selection model in most GUI editors: after selecting text, any printable character you type replaces the selection a
category:
visual-mode
tags:
#visual-mode
#select-mode
#editing
#normal-mode
How do I keep concealed text hidden while navigating but automatically reveal it when my cursor enters insert mode?
The 'concealcursor' option controls in which modes concealed text is revealed on the cursor line.
category:
config
tags:
#config
#display
#editing
#concealment
How do I save a file with specific line endings in one command without changing the buffer's fileformat setting?
The ++ff modifier on :w forces the file format used for writing, independently of the buffer's 'fileformat' option.
category:
command-line
tags:
#ex-commands
#formatting
#command-line
#editing
How do I replace only the current match and then stop when doing an interactive substitution in Vim?
l (in :%s///gc confirm prompt)
When running an interactive substitution with the c flag (e.
category:
editing
tags:
#search
#editing
#substitution
#ex-commands
#normal-mode
How do I format and pretty-print JSON in the current Vim buffer using Python?
When editing JSON files in Vim, you can pipe the entire buffer through Python's built-in json.
category:
editing
tags:
#editing
#formatting
#ex-commands
#json
#shell