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 by @Kai22832:

Unlock 8 remaining solutions by signing in and submitting your own entry
Created by: @Flurrywinde

172 active golfers, 327 entries

Solutions by @Kai22832:
12
#103 - Zhao Kai / @Kai22832

10/21/2022 at 03:17AM

12
#>103 - Zhao Kai / @Kai22832

10/21/2022 at 03:23AM

13
#>155 - Zhao Kai / @Kai22832

10/21/2022 at 03:12AM

14
#>164 - Zhao Kai / @Kai22832

10/21/2022 at 03:11AM

15
#>167 - Zhao Kai / @Kai22832

10/21/2022 at 03:09AM

17
#>168 - Zhao Kai / @Kai22832

10/21/2022 at 03:04AM

18
#>169 - Zhao Kai / @Kai22832

10/21/2022 at 02:53AM

21
#>172 - Zhao Kai / @Kai22832

10/21/2022 at 02:22AM