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
#31 - Kirill Cherkashin / @kirjs

08/31/2015 at 08:39PM

12
#32 - Aleksandr Block / @AleksandrBlock

09/01/2015 at 07:02AM

12
#33 - Jinzhou Zhang / @jinzhouz

09/02/2015 at 09:57AM

12
#34 - oscar / @zonza_mas

09/02/2015 at 01:01PM

12
#35 - Mart T / @xtimmu

09/02/2015 at 07:26PM

12
#36 - Restroom Sounds / @RestroomSounds

09/06/2015 at 01:54AM

12
#37 - Yaroslav Kanarev / @yarosurabu

09/07/2015 at 03:36PM

12
#38 - 0e4ef622 / @0e4ef622

09/13/2015 at 03:42PM

12
#39 - luffy / @raxcoi

09/13/2015 at 06:49PM

12
#40 - Marcin Szamotulski / @me_coot

09/15/2015 at 07:57AM

12
#41 - Kevin Merlin / @mp3merlin

09/17/2015 at 03:39PM

12
#42 - Victor Kasatkin / @vikasatkin

09/20/2015 at 11:24PM

12
#43 - Thomas Draper / @QuanTom561

09/26/2015 at 02:31AM

12
#44 - Hello World / @CrisTsanNtua

09/27/2015 at 12:15PM

12
#45 - Mike Adams / @davis_cromwell

09/27/2015 at 09:27PM

12
#46 - Self Doc Code / @self_doc_code

09/28/2015 at 07:12AM

12
#47 - Walker Boh / @walker_boh

09/30/2015 at 01:55PM

12
#48 - Jon Krause / @jkrause314

10/02/2015 at 06:02AM

12
#49 - Julian Andrews / @NoLemurs

10/03/2015 at 08:37PM

12
#50 - ojung / @oskrjung

10/05/2015 at 01:11AM

12
#51 - Ben Crowder / @bencrowder

10/07/2015 at 02:05PM

12
#52 - "Smylers" / @Smylers2

10/08/2015 at 06:37PM

12
#53 - Mark Brody / @_markbrody

10/15/2015 at 03:10PM

12
#54 - 朱国栋 / @GuodongZhu

10/15/2015 at 03:20PM

12
#55 - Domingue Justin / @_jdomingue

10/15/2015 at 04:34PM

12
#56 - Stani Banani / @Stani_Banani

10/16/2015 at 07:03PM

12
#57 - merphant / @merphant

10/23/2015 at 12:57AM

12
#58 - Bogumił Kamiński / @BogumilKaminski

10/25/2015 at 04:14PM

12
#59 - Peter / @sunirbmag

10/25/2015 at 10:00PM

12
#60 - Justin Sermeno / @justinsermeno

11/01/2015 at 07:03PM