How do I increment and decrement dates, times, and other structured sequences in Vim?
<C-a> / <C-x> (vim-speeddating)
vim-speeddating (by Tim Pope) extends Vim's built-in and increment/decrement operators to understand dates, times, roman numerals, and other ordered sequences.
category:
plugins
tags:
#plugins
#editing
#normal-mode
How do you record a macro to join every other line pair?
Record a macro that joins the current line with the next using J, then moves down one line with j.
category:
macros
tags:
#macros
#join
#lines
How do you copy a range of lines to another location?
Use :t (copy) with a range and destination.
category:
command-line
tags:
#command-line
#copy
#lines
How do I save a recorded macro permanently so it persists across Vim sessions?
let @a = 'macro_contents'
Recorded macros are stored in registers, which are lost when you quit Vim (unless viminfo saves them).
category:
macros
tags:
#macros
#config
#registers
#vimrc
#productivity
How do I run a shell command from Vimscript and capture its output as a list of individual lines?
systemlist({cmd}) runs a shell command and returns the output as a list of strings, one per line — unlike system() which returns everything as a single string
category:
command-line
tags:
#vimscript
#ex-commands
#registers
#macros
How do you record a macro to convert 4-space indentation to 2-space?
Record a macro that substitutes leading 4-space indentation with 2 spaces on each line.
category:
macros
tags:
#macros
#indentation
#convert
How do you use a macro to convert spaces in words to underscores?
Record a macro that finds the next space with f and replaces it with an underscore using r_.
category:
macros
tags:
#macros
#spaces
#underscores
How do you record a macro to swap the current line with the one below?
Record a macro that deletes the current line with dd and pastes it below the next line with p.
category:
macros
tags:
#macros
#swap
#lines
How do I use a Vim expression to dynamically compute the replacement in a substitution?
:s/\d\+/\=submatch(0)+1/g
The \= prefix in a :substitute replacement field tells Vim to evaluate the following as a Vimscript expression rather than treating it as a literal string.
category:
registers
tags:
#search
#editing
#ex-commands
#registers
How do you switch to a buffer by its number?
Use :b followed by the buffer number.
category:
buffers-windows
tags:
#buffers
#switch
#number
How do I create incrementing number sequences in Vim?
The g command increments numbers across a visual selection so that each subsequent line gets a progressively higher value.
category:
visual-mode
tags:
#visual-mode
#editing
#normal-mode
How do you record a macro to clean log file lines by removing timestamps?
Record a macro that goes to the start of the line, deletes the first two words (timestamp fields), then moves down.
category:
macros
tags:
#macros
#log
#cleanup
How do you use Oil.nvim as a file manager in Neovim?
Oil.
category:
plugins
tags:
#plugins
#oil
#file-manager
How do I convert a recorded macro into a permanent key mapping?
:let @q then use in nnoremap
Macros are stored in registers as plain keystroke strings.
category:
macros
tags:
#macros
#config
#vimrc
#mappings
#workflow
How do I decrement a visual block of numbers as a sequence?
Most people know decrements one number under the cursor, but g in Visual mode performs a sequential decrement across the selection.
category:
visual-mode
tags:
#visual-mode
#editing
#numbers
#normal-mode
How do you insert the current filename from a register?
In insert mode, % inserts the current filename.
category:
registers
tags:
#registers
#filename
#insert
How do you use a macro to delete the first word of every line?
Record a macro that goes to the start of line with 0, deletes the first word with dw, and moves down with j.
category:
macros
tags:
#macros
#delete
#first-word
How do you use the expression register to insert a calculation?
In insert mode, press = to access the expression register, type a math expression like 42*7, and press Enter to insert the result (294).
category:
registers
tags:
#registers
#expression
#calculation
How do you edit a command in the command-line window?
While typing a command, press to open the command-line editing window.
category:
command-line
tags:
#command-line
#edit
#window
How do you move a range of lines to another location?
Use :m (move) with a range and destination.
category:
command-line
tags:
#command-line
#move
#lines