How do you record a macro to split a long line at a certain column?
qa80|i\n<Esc>jq
Record a macro that moves to column 80 using 80 , inserts a newline, and moves to the next line.
Search Vim Tricks
Searching...qa80|i\n<Esc>jq
Record a macro that moves to column 80 using 80 , inserts a newline, and moves to the next line.
qayy:+1\nif getline('.')==@0|d|else|+1|endif\nq
Record a macro that yanks the current line and compares it with the next.
qa:s/\s\+$//e\n jq
Record a macro that runs a substitution on the current line to remove trailing spaces, then moves down.
qa$bywdw0Pa <Esc>q
Record a macro that yanks the last word, deletes it, pastes it at the beginning of the line.
qaI<C-r>a<Esc>jq
Record a macro that inserts the contents of register a at the start of each line using a in insert mode, then moves down.
qaf,i"<Esc>la"<Esc>q
Record a macro that finds the next comma, inserts a quote before it, moves past the comma, and inserts a quote after.
qa/^#\nddq
Record a macro that finds lines starting with # and deletes them.
qaJjq
Record a macro that joins the current line with the next using J, then moves down one line with j.
qa{jI## Section \n<Esc>}q
Record a macro that goes to the start of each paragraph and inserts a section header.
50@a
Prefix the macro playback command with a count.
qaYp<C-a>q
Record a macro that yanks the current line, pastes it below, and increments the number with .
qaI <Esc>jq
Record a macro that inserts two spaces at the beginning of the line and moves down.
qaA <C-r>=strftime('%Y-%m-%d')\n<Esc>jq
Record a macro that appends a date stamp using the expression register with strftime().
qa0f dwi\n<Esc>jq
Extract columns by recording a macro that navigates to the desired field and deletes or yanks it.
qa/https\?:\/\/\nyiW:put\nq
Record a macro that searches for URLs, yanks the URL, and puts it at the end of the file.
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.
:let i=1\nqao<C-r>=i\n<Esc>:let i+=1\nq
Use a counter variable with the expression register inside a macro.
qayyp:s/old/new/\nq
Record a macro that yanks and pastes the current line, then substitutes text on the new line.
:let @a='<C-r>a'
Paste the macro register contents with :let @a=' followed by a to insert the current contents, edit them, and close the quote.
qaciwi(<C-r>")<Esc>wq
Record a macro that changes the inner word, types an opening paren, pastes the original word, types a closing paren, and moves to the next word.