Skip to main content
Post Undeleted by DJMcMayhem
deleted 447 characters in body
Source Link
DJMcMayhem
  • 59.6k
  • 17
  • 196
  • 348

#Vim 17 bytes

V, 9 bytes

:h<cr>Wy$ZZii{"<C-r>"""¹*":0}

Try it online!Try it online!

This outputsVery straightforward. Enters insert mode, enters the following text:

{"For Vim version 8.0.  Last change: 2016 Mar 31""*********":0}

For me. The output slightly varies depending on which version you use.

Explanation:

First, we open up vim's builtin help file. The text onreason this line is:

*help.txt*<tab>For Vim version 8.0.  Last change: 2016 Mar 31

We could simply do Y to yank the whole line, but tabs are invalid in JSON. So we move forward one word with W, then yank to the end of the line with y$. Then we save and close this file with ZZ.

From here, we simply enter insert mode, and use so short is because <C-r>"¹ to insert the yanked text inrepeats the appropriate placefollowing character 9 times.

#Vim 17 bytes

:h<cr>Wy$ZZi{"<C-r>"":0}

Try it online!

This outputs:

{"For Vim version 8.0.  Last change: 2016 Mar 31":0}

For me. The output slightly varies depending on which version you use.

Explanation:

First, we open up vim's builtin help file. The text on this line is:

*help.txt*<tab>For Vim version 8.0.  Last change: 2016 Mar 31

We could simply do Y to yank the whole line, but tabs are invalid in JSON. So we move forward one word with W, then yank to the end of the line with y$. Then we save and close this file with ZZ.

From here, we simply enter insert mode, and use <C-r>" to insert the yanked text in the appropriate place.

V, 9 bytes

i{"¹*":0}

Try it online!

Very straightforward. Enters insert mode, enters the following text:

{"*********":0}

The reason this is so short is because ¹ repeats the following character 9 times.

Post Deleted by DJMcMayhem
Source Link
DJMcMayhem
  • 59.6k
  • 17
  • 196
  • 348

#Vim 17 bytes

:h<cr>Wy$ZZi{"<C-r>"":0}

Try it online!

This outputs:

{"For Vim version 8.0.  Last change: 2016 Mar 31":0}

For me. The output slightly varies depending on which version you use.

Explanation:

First, we open up vim's builtin help file. The text on this line is:

*help.txt*<tab>For Vim version 8.0.  Last change: 2016 Mar 31

We could simply do Y to yank the whole line, but tabs are invalid in JSON. So we move forward one word with W, then yank to the end of the line with y$. Then we save and close this file with ZZ.

From here, we simply enter insert mode, and use <C-r>" to insert the yanked text in the appropriate place.