vimgolf: Simple, Practical, and Common

Start file

*temp var1 0
*temp var2 "hi"
*temp var3 -1
*temp var4 42
*temp var5 "asdf"
*temp var6 0

Simple things we do all the time should be able to be done with very few keystrokes, but sometimes I find something I need to do makes me go, "There MUST be a better way."

This challenge is just a simple movement and entering text at a certain place.

End file

*temp var1 0
*temp var2 "hi"
*temp var3 -1
*temp var4 42
*temp var5 "asdf"
*temp var6 0
*temp var7 11

Simple things we do all the time should be able to be done with very few keystrokes, but sometimes I find something I need to do makes me go, "There MUST be a better way."

New text.

This challenge is just a simple movement and entering text at a certain place.

Solution

6GYp<C-A>w11<C-A>GONew t<C-N><C-N>.<CR><Esc>ZZ

Moving down

5j
moving down to line var6
6G
Go to line 6

Copying and pasting

Yp
yank line and put

Increase count

CTRL-A
increase 6 to 7
w
move to next word
[count]CTRL-A
increase by count [count], in this case count = 11

Move to end

GO
Go to end and Open a line above

Start typing

New t<C-N><C-N>.<CR>
this has the interesting effect of searching forward for the words beginning with t.

Comments

Comments powered by Disqus