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
#91 - Daniël De Koker / @daniel_koker

07/26/2018 at 08:48PM

12
#92 - albalitz / @_albalitz

06/18/2019 at 01:30PM

12
#93 - Lory / @Lory46845742

12/10/2019 at 02:38PM

12
#94 - Miłosz Łakomy / @foobar01123

02/28/2020 at 11:26AM

12
#95 - Tim Smart / @tim_smart

05/08/2020 at 07:36AM

12
#96 - Fabien C. / @vaga_io

05/18/2020 at 09:59AM

12
#97 - RockerZZY / @rocker_zzy

06/27/2020 at 11:28PM

12
#98 - 김범준 / @kmbmjn

03/10/2021 at 11:53AM

12
#99 - Jean George / @JeanGeo20504212

03/25/2022 at 02:01PM

12
#100 - Alex / @AlexanderHeatl2

05/22/2022 at 05:01PM

12
#101 - Manavi Ghorpade / @ManaviGhorpade

09/26/2022 at 12:06AM

12
#102 - Janzen / @__Coos

10/03/2022 at 12:27PM

12
#103 - Zhao Kai / @Kai22832

10/21/2022 at 03:17AM

12
#104 - Berkay Berabi / @BerkayBerabi

03/04/2023 at 06:21PM

12
#105 - RosaTryp / @RosaTryp

06/09/2023 at 12:23PM

12
#106 - Jacob / @FuPingstar

02/01/2024 at 06:54PM

12
#107 - jonas-grobe / @jonas-grobe

02/04/2024 at 01:18PM

12
#108 - Anaritus / @Anaritus

02/26/2024 at 05:24PM

12
#109 - Berel94 / @Berel94

03/14/2024 at 10:02PM

12
#110 - Kanmuruuruu / @Kanmuruuruu

04/19/2024 at 07:17PM

12
#111 - constap / @constap

05/13/2024 at 06:53PM

12
#112 - Peppa Pig / @PeppaPigSg

07/20/2024 at 01:17AM

13
#113 - Lifepillar / @lifepillar

08/21/2015 at 07:37PM

13
#114 - Christophe Sicard / @tophsic

08/21/2015 at 07:58PM

13
#115 - James / @Dronak

08/21/2015 at 08:59PM

13
#116 - LC / @leeren

08/21/2015 at 10:31PM

13
#117 - JS / @jjohsan

08/22/2015 at 09:31AM

13
#118 - Matt / @mcr05

08/22/2015 at 03:58PM

13
#119 - Thanh ND / @thanhnd84

08/23/2015 at 09:10AM

13
#120 - gyermolenko / @gyermolenko_

08/24/2015 at 06:26PM