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):
13
#151 - Michael Meixner / @meixner62

01/24/2020 at 12:04PM

13
#152 - Jason / @jason_eveleth

07/23/2020 at 08:33AM

13
#153 - pikjes / @pikjes2

03/25/2021 at 02:02PM

13
#154 - russellzhaomao / @russellzhaomao

06/30/2022 at 12:10AM

13
#155 - Brandon / @Brandon10678836

08/26/2022 at 02:09PM

13
#156 - James Marshall / @astrophd

10/21/2022 at 02:21AM

13
#157 - vimgolfaccfekxh / @vimgolfaccfekxh

10/30/2022 at 08:00PM

14
#158 - alex / @alexAngle8

08/21/2015 at 07:53PM

14
#159 - Taylor Andrews / @xtaylorandrewsx

09/02/2015 at 01:29AM

14
#160 - David Stimpert / @DavidStimpert

09/23/2015 at 01:18AM

14
#161 - Marcus Buffett / @MarcusBuffett

10/05/2015 at 04:49AM

14
#162 - NuM / @NuM314

10/24/2015 at 06:51AM

14
#163 - Cristian Lupașcu / @clupasq

02/22/2016 at 03:05PM

14
#164 - Gurukandhamoorthi / @Gurukandhamoor1

07/14/2017 at 05:40PM

14
#165 - Ephi Gabay / @lsdisme

05/27/2020 at 07:48AM

15
#166 - darfontz sucks / @buttsToTheSky

08/25/2015 at 05:34PM

15
#167 - Jay Hack / @_jayhack_

12/11/2015 at 08:50PM

15
#168 - Brent Woo / @BrentPWoo

10/01/2018 at 08:45PM

15
#169 - Olivier Bégassat / @zk_evm

06/13/2023 at 12:32PM

18
#170 - Illuminati Tsaur / @IlluminatiTsaur

08/26/2015 at 12:05PM

18
#171 - nickGPT / @nickandbro

08/28/2024 at 03:56AM

19
#172 - Filype / @FilypePereira

09/26/2015 at 09:38AM

20
#173 - Omar Alawadhi / @OmarAla59544225

10/19/2022 at 05:47PM

21
#174 - Theodore DeRego / @tedsta0

12/08/2015 at 03:20AM