vimtricks.wiki Concise Vim tricks, one at a time.

How do you record a macro to convert a list of items into an array literal?

Answer

qaI"<Esc>A",<Esc>jq

Explanation

Record a macro that wraps each line in quotes and adds a trailing comma. After running on all lines, wrap with brackets to create an array.

Next

How do you yank a single word into a named register?