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

0 comments


Created by: @Flurrywinde

141 active golfers, 263 entries

Leaderboard (lowest score wins):
12
#91 - Daniël De Koker / @daniel_koker

07/26/2018 at 08:48PM

13
#92 - Lifepillar / @lifepillar

08/21/2015 at 07:37PM

13
#93 - Christophe Sicard / @tophsic

08/21/2015 at 07:58PM

13
#94 - James / @Dronak

08/21/2015 at 08:59PM

13
#95 - LC / @leeren

08/21/2015 at 10:31PM

13
#96 - JS / @jjohsan

08/22/2015 at 09:31AM

13
#97 - Matthieu Crapet / @mcr05

08/22/2015 at 03:58PM

13
#98 - Thanh ND / @thanhnd84

08/23/2015 at 09:10AM

13
#99 - gyermolenko / @gyermolenko_

08/24/2015 at 06:26PM

13
#100 - daniel olsson / @glajan

08/27/2015 at 05:10PM

13
#101 - Osleg aka Akira ^_^ / @4k1r4

08/28/2015 at 03:16AM

13
#102 - Léo S / @LeoSauvaget

08/28/2015 at 12:34PM

13
#103 - Mikołaj Morzy / @MikolajMorzy

09/01/2015 at 09:09PM

13
#104 - A / @Tower_1980

09/03/2015 at 12:41PM

13
#105 - Nicholas Marrone / @nickmarrone

09/05/2015 at 10:42PM

13
#106 - Mika .B / @Michael_Ben_Ali

09/10/2015 at 02:26PM

13
#107 - Joey / @joeyism101

09/12/2015 at 02:54PM

13
#108 - dd / @dd22147119

09/14/2015 at 03:04PM

13
#109 - Alex Bartol / @alexbartol

09/15/2015 at 05:58PM

13
#110 - Shreyas Kulkarni / @ghatotkatch

09/15/2015 at 07:43PM

13
#111 - Tamas Gal (Tom) / @tamasgal

09/26/2015 at 08:11AM

13
#112 - Sam Cristall / @sbcristall

09/28/2015 at 05:23PM

13
#113 - Slavisa Djukic / @ssdjuka

09/30/2015 at 09:52PM

13
#114 - ggdGiBork:3^[:wq / @CopperBadger

10/06/2015 at 12:57AM

13
#115 - Ronnie McCall / @RonnieMcC

10/07/2015 at 01:23AM

13
#116 - Pin / @ponfelipon

10/08/2015 at 05:18PM

13
#117 - Anshu Avinash / @anshu_avinash

10/17/2015 at 10:17PM

13
#118 - roboguy / @roboguy

10/19/2015 at 04:33AM

13
#119 - Shobhit Gupta / @shobhitg

10/26/2015 at 09:18PM

13
#120 - mnx / @mnxx

11/15/2015 at 05:52PM