Replace pattern with 1, 2, 3, ... on each line
For each line replace a search pattern (in this case $) with numbers starting at 1 and then increasing by 1 for each replaced match. a$b$c$ -> a0b1c2
Start file
I can't see the $ for all the $,
But there $ not $ $ tomorrow.
$ she can do $ and 4,
$ the $ in the $ and $ the $.
End file
I can't see the 1 for all the 2,
But there 1 not 2 3 tomorrow.
1 she can do 2 and 4,
1 the 2 in the 3 and 4 the 5.
View Diff
1,4c1,4
< I can't see the $ for all the $,
< But there $ not $ $ tomorrow.
< $ she can do $ and 4,
< $ the $ in the $ and $ the $.
\ No newline at end of file
---
> I can't see the 1 for all the 2,
> But there 1 not 2 3 tomorrow.
> 1 she can do 2 and 4,
> 1 the 2 in the 3 and 4 the 5.
\ No newline at end of file
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 231 remaining solutions by signing in and submitting your own entry
#232 shahanavaz m / @shahanavazm - Score: 134 - 03/28/24 @ 23:54
:let c=0|exe "function! C() \n let c+=1 \n return<Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left>g:<Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right> g:c \n endfunction"<CR>:g/\$/s//\=C)H<C-H><C-H>()/g|let g<BS>c=0<CR>ZZ
0 comments