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 173 remaining solutions by signing in and submitting your own entry
#174 Theodore DeRego / @tedsta0 - Score: 21 - 12/08/15 @ 03:20
j$ie<Esc>vyjqgPj$q4@g:wq<CR>

0 comments


Created by: @Flurrywinde

174 active golfers, 333 entries

Leaderboard (lowest score wins):
12
#1 - Urtica dioica / @udioica

08/21/2015 at 06:36PM

12
#2 - Tim Chase / @gumnos

08/21/2015 at 06:36PM

12
#3 - Anoop Kumar / @anooplive

08/21/2015 at 06:41PM

12
#4 - John Braxler / @braxler

08/21/2015 at 08:43PM

12
#5 - Louis Burke / @LambdaABeta

08/21/2015 at 09:02PM

12
#6 - Kai Yuan / @kentyuan

08/21/2015 at 09:34PM

12
#7 - Petro Тrouq / @zulolosi

08/22/2015 at 01:26AM

12
#8 - jyloup / @jyloup

08/22/2015 at 10:25AM

12
#9 - Martin Galpin / @MartinRGalpin

08/22/2015 at 03:16PM

12
#10 - joinvimgolf / @joinvimgolf

08/22/2015 at 05:44PM

12
#11 - Mutter Mumble / @muttermumble

08/22/2015 at 06:21PM

12
#12 - randomizer user / @alsdkfhjlkadfha

08/22/2015 at 08:08PM

12
#13 - Blake Tereau / @BlakeTereau

08/22/2015 at 10:01PM

12
#14 - Dennis Burke / @ikirudennis

08/22/2015 at 10:47PM

12
#15 - ZC-死理性派 / @zecyzhang

08/23/2015 at 01:34PM

12
#16 - Paulo Romeira / @pauloromeira

08/24/2015 at 02:23AM

12
#17 - raghu erapaneedi / @raghue9

08/24/2015 at 10:22AM

12
#18 - I / @ForgetIt17

08/24/2015 at 11:17AM

12
#19 - Bart / @oneofmanybarts

08/24/2015 at 11:33AM

12
#20 - Dennis Li / @_DennisLi

08/25/2015 at 06:54AM

12
#21 - Elizabeth / @sprinkles418

08/25/2015 at 04:16PM

12
#22 - Jason Schulz / @uxcn_

08/26/2015 at 05:18AM

12
#23 - Dan Moldovan / @Lenea92

08/26/2015 at 01:35PM

12
#24 - Po-Ying Chen / @PoYingChen

08/26/2015 at 03:10PM

12
#25 - Ryan / @eatsleephack_

08/27/2015 at 01:40AM

12
#26 - Martin Delille / @martinodelilo

08/28/2015 at 10:31AM

12
#27 - Rudolfs Sohn / @rudolf_son

08/28/2015 at 01:22PM

12
#28 - S.Lebedev / @drasgo

08/28/2015 at 10:14PM

12
#29 - T A / @SirAviles

08/29/2015 at 03:21PM

12
#30 - Sime Buljac / @sim_bul

08/31/2015 at 03:21PM