I am proficient in Vi Improved and regular expressions. So, I used that.
- Create a dummy Focus.
- Back up the Focus to create an example JSON object.
- Copy the .focus code from GitHub.
- Copy the title from the GitHub code into the example JSON.
Then I used commands specific to Vim:
- Use a visual block selection to delete the leading characters.
- Use :substitute to replace the newlines with commas.
- Manually trim the trailing comma.
Screen Recording
I used the following substitute command in the screen capture:
:'<,'>s/\n/,
where
- Colon : triggers a Vim command.
- Single quote and left angle bracket '< refers to the beginning of the selected sites.
- The comma , separates the selection range (cmdline-range).
- Single quote and right angle bracket '> refers to the end of the selection.
- s is short for the substitute command.
- Forward slash / separates the elements of the find and replace expression.
- Backslash n (
\n
) is the escape code for a newline. - Forward slash / separates the elements of the find and replace expression.
- The final comma , represents a literal comma.
I would read this aloud as:
“Substitute commas for newlines within the visual selection.”