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 108 remaining solutions by signing in and submitting your own entry
#109 Shreyas Kulkarni / ghatotkatch - Score: 13 - 09/15/15 @ 19:43
:%s/'$/e'/<CR>ZZ

0 comments


#110 Tamas Gal (Tom) / tamasgal - Score: 13 - 09/26/15 @ 08:11
qq2$ie<Esc>q5@qZZ

0 comments


#111 Sam Cristall / sbcristall - Score: 13 - 09/28/15 @ 17:23
:%s/c'/ce'<CR>ZZ

0 comments


#112 Slavisa Djukic / ssdjuka - Score: 13 - 09/30/15 @ 21:52
qaj$ie<Esc>q5@aZZ

0 comments


#113 ggdGiBork:3^[:wq / CopperBadger - Score: 13 - 10/06/15 @ 00:57
qaj$ie<Esc>q5@aZZ

0 comments


#114 Ronnie McCall / RonnieMcC - Score: 13 - 10/07/15 @ 01:23
:%s/c'/ce'<CR>ZZ

0 comments


#115 Pin / ponfelipon - Score: 13 - 10/08/15 @ 17:18
qqj$ie<Esc>q5@qZZ

0 comments


#116 Anshu Avinash / anshu_avinash - Score: 13 - 10/17/15 @ 22:17
qaj$ie<Esc>q5@aZZ

0 comments


#117 roboguy / roboguy - Score: 13 - 10/19/15 @ 04:33
:%s/c'/ce'<CR>ZZ

0 comments


#118 Shobhit Gupta / shobhitg - Score: 13 - 10/26/15 @ 21:18
qaj$ie<Esc>q5@aZZ

0 comments


#119 mnx / mnxx - Score: 13 - 11/15/15 @ 17:52
qqj$ie<Esc>q5@qZZ

0 comments


#120 Andre Danielsson / DanielssonAndre - Score: 13 - 02/08/16 @ 20:13
qqj$ie<Esc>q5@qZZ

0 comments


#121 Kyouma / kyoumaJohn - Score: 13 - 10/14/16 @ 19:33
:%s/c'/ce'<CR>ZZ

0 comments


#122 Alexander Gryson / agryson - Score: 13 - 05/01/17 @ 16:12
qqj$ie<Esc>q5@qZZ

0 comments


#123 Remus Dalrymple / bornintheflames - Score: 13 - 05/09/17 @ 06:56
qqj$ie<Esc>q5@qZZ

0 comments


#124 alex / alexAngle8 - Score: 14 - 08/21/15 @ 19:53
:%s/c'/ce'/<CR>ZZ

0 comments


#125 Taylor Andrews / xtaylorandrewsx - Score: 14 - 09/02/15 @ 01:29
jqq$ie<Esc>jq5@qZZ

0 comments


#126 David Stimpert / DavidStimpert - Score: 14 - 09/23/15 @ 01:18
qqj$ie<Esc>0q5@qZZ

0 comments


#127 Marcus Buffett / MarcusBuffett - Score: 14 - 10/05/15 @ 04:49
jqq$ie<Esc>jq5@qZZ

0 comments


#128 NuM / NuM314 - Score: 14 - 10/24/15 @ 06:51
:%s_/c_&e_g|x<CR>

0 comments


#129 Cristian Lupașcu / clupasq - Score: 14 - 02/22/16 @ 15:05
$jh*:%s//ce<CR>ZZ

0 comments


#130 Gurukandhamoorthi / Gurukandhamoor1 - Score: 14 - 07/14/17 @ 17:40
jqq$ie<Esc><CR>q5@qZZ

0 comments


#131 darfontz sucks / buttsToTheSky - Score: 15 - 08/25/15 @ 17:34
qaj$ie<Esc>q5@a:wq<CR>

0 comments


#132 Jay Hack / _jayhack_ - Score: 15 - 12/11/15 @ 20:50
:%s/'$/e'/g<CR><Esc>ZZ

0 comments


#133 Illuminati Tsaur / IlluminatiTsaur - Score: 18 - 08/26/15 @ 12:05
:%sc'<Left><Left>/<Right><Right>/ce'<CR>:x<CR>

0 comments


#134 Filype Pereira / FilypePereira - Score: 19 - 09/26/15 @ 09:38
jA<Left>e<Esc><Down>.<Down><Right>.<Down>.<Down>.<Down>.<Esc>ZZ

0 comments


#135 Theodore DeRego / tedsta0 - Score: 21 - 12/08/15 @ 03:20
j$ie<Esc>vyjqgPj$q4@g:wq<CR>

0 comments


Created by: Flurrywinde

135 active golfers, 247 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