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.
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.
qa/^$/\ndd@aq
Record a macro that searches for blank lines, deletes them, and recurses.
qa0dwjq
Record a macro that goes to the start of line with 0, deletes the first word with dw, and moves down with j.
qad/pattern\nq
Record a macro that deletes from the cursor to the next match of a pattern using d/pattern.
qa:s/\t/ /g\njq
Record a macro that substitutes all tabs with spaces on the current line, then moves down.
qa/pattern\nyy}pq
Record a macro that searches for a pattern, yanks the matching line, goes to the end of the paragraph, and pastes it.
qaI| <Esc>:s/,/ | /g\nA |<Esc>jq
Record a macro that adds pipe delimiters around CSV fields, converting each line to a Markdown table row format.
qayiWi[<Esc>ea](<Esc>pa)<Esc>q
Record a macro that yanks the URL, wraps the text before it in brackets, and appends the URL in parentheses for Markdown link format.
qaf'r"q
Record a macro that finds the next single quote with f' and replaces it with a double quote using r".
qaf r_q
Record a macro that finds the next space with f and replaces it with an underscore using r_.
qa:s/^ / /\njq
Record a macro that substitutes leading 4-space indentation with 2 spaces on each line.
qa0d2Wjq
Record a macro that goes to the start of the line, deletes the first two words (timestamp fields), then moves down.
qaI"<Esc>A",<Esc>jq
Record a macro that wraps each line in quotes and adds a trailing comma.
qa*Ncgn<C-r>=newName\n<Esc>q
Record a macro using * to search for the word under cursor, cgn to change the next match, type the new name.
qa/[A-Z]\ni_<Esc>l~q
Record a macro that finds the next uppercase letter, inserts an underscore before it, and lowercases it.
qa0f=40i <Esc>040lDjq
Record a macro that inserts spaces before = to pad to column 40, then trims excess.