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