Real Vim ninjas count every keystroke - do you?

Pick a challenge, fire up Vim, and show us what you got.

Changelog, Rules & FAQ, updates: @vimgolf, RSS.

Your VimGolf key: please sign in

$ gem install vimgolf
$ vimgolf setup
$ vimgolf put 55d7692d134b34420f05ac0b

Add to end of each line... kinda

Visual-block mode can be used to add something to the end of each line, even if they are of differing lengths. However, what if it's not quite at the end?

Start file
function! FixLatexChars() 
	execute '%s/\\/\\textbackslash{}/c'
	execute '%s/#/\\#/c'
	execute '%s/\$/\\$/c'
	execute '%s/%/\\%/c'
	execute '%s/&/\\&/c'
	execute '%s/_/\\_/c'
endfunction
End file
function! FixLatexChars() 
	execute '%s/\\/\\textbackslash{}/ce'
	execute '%s/#/\\#/ce'
	execute '%s/\$/\\$/ce'
	execute '%s/%/\\%/ce'
	execute '%s/&/\\&/ce'
	execute '%s/_/\\_/ce'
endfunction

View Diff

2,7c2,7
< 	execute '%s/\\/\\textbackslash{}/c'
< 	execute '%s/#/\\#/c'
< 	execute '%s/\$/\\$/c'
< 	execute '%s/%/\\%/c'
< 	execute '%s/&/\\&/c'
< 	execute '%s/_/\\_/c'
---
> 	execute '%s/\\/\\textbackslash{}/ce'
> 	execute '%s/#/\\#/ce'
> 	execute '%s/\$/\\$/ce'
> 	execute '%s/%/\\%/ce'
> 	execute '%s/&/\\&/ce'
> 	execute '%s/_/\\_/ce'

Solutions

The best way to learn is to practice. Below, you will find some of the solutions other golfers have entered. To unlock higher ranked solutions, submit your own entry which does as well or better than the solutions you can currently see - climb the ladder!

Check out these helpful resources to improve your Vim skills... Game on.

Unlock 145 remaining solutions by signing in and submitting your own entry
#146 Theodore DeRego / @tedsta0 - Score: 21 - 12/08/15 @ 03:20
j$ie<Esc>vyjqgPj$q4@g:wq<CR>

0 comments


Created by: @Flurrywinde

146 active golfers, 269 entries

Leaderboard (lowest score wins):
13
#121 - roboguy / @roboguy

10/19/2015 at 04:33AM

13
#122 - Shobhit Gupta / @shobhitg

10/26/2015 at 09:18PM

13
#123 - mnx / @mnxx

11/15/2015 at 05:52PM

13
#124 - Andre Danielsson / @DanielssonAndre

02/08/2016 at 08:13PM

13
#125 - Kyouma / @kyoumaJohn

10/14/2016 at 07:33PM

13
#126 - Alexander Gryson / @agryson

05/01/2017 at 04:12PM

13
#127 - Remus Dalrymple / @bornintheflames

05/09/2017 at 06:56AM

13
#128 - Timothée Gauthier / @zmf_tim

08/04/2018 at 09:11PM

13
#129 - Jurica / @Jurica34581259

12/06/2018 at 03:51AM

13
#130 - Mihai / @mihaicristiant

02/04/2019 at 12:41PM

13
#131 - Mateen Ulhaq / @sicariusnoctis

02/12/2019 at 02:25AM

13
#132 - yokibahim / @yokibahim

10/21/2019 at 07:32PM

13
#133 - Michael Meixner / @meixner62

01/24/2020 at 12:04PM

14
#134 - alex / @alexAngle8

08/21/2015 at 07:53PM

14
#135 - Taylor Andrews / @xtaylorandrewsx

09/02/2015 at 01:29AM

14
#136 - David Stimpert / @DavidStimpert

09/23/2015 at 01:18AM

14
#137 - Marcus Buffett / @MarcusBuffett

10/05/2015 at 04:49AM

14
#138 - NuM / @NuM314

10/24/2015 at 06:51AM

14
#139 - Cristian Lupașcu / @clupasq

02/22/2016 at 03:05PM

14
#140 - Gurukandhamoorthi / @Gurukandhamoor1

07/14/2017 at 05:40PM

15
#141 - darfontz sucks / @buttsToTheSky

08/25/2015 at 05:34PM

15
#142 - Jay Hack / @_jayhack_

12/11/2015 at 08:50PM

15
#143 - Brent Woo / @BrentPWoo

10/01/2018 at 08:45PM

18
#144 - Illuminati Tsaur / @IlluminatiTsaur

08/26/2015 at 12:05PM

19
#145 - Filype Pereira / @FilypePereira

09/26/2015 at 09:38AM

21
#146 - Theodore DeRego / @tedsta0

12/08/2015 at 03:20AM