Reformat symbols in list
Saw this in some lecture, easy reformatting using multiple cursor in VS Code
Start file
inputs = [ 1 2 3 4 5 ] outputs = [ 1 2 3 4 5 ]
End file
inputs = [ i1 i2 i3 i4 i5 ] outputs = [ (o1,i1) (o2,i2) (o3,i3) (o4,i4) (o5,i5) ]
View Diff
1,2c1,2 < inputs = [ 1 2 3 4 5 ] < outputs = [ 1 2 3 4 5 ] --- > inputs = [ i1 i2 i3 i4 i5 ] > outputs = [ (o1,i1) (o2,i2) (o3,i3) (o4,i4) (o5,i5) ]
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 346 remaining solutions by signing in and submitting your own entry
#347 陈宏义 / @mason_chen_cn - Score: 202 - 09/12/22 @ 15:29
<Esc>:1,1s/[]<Left>0<BS>1-5<Right><Left><Left><Left><Left><Left>(<Right><Right><Right><Right><Right>)/i$1/g<CR>/<BS>:1s/([1-5]+)/i()<BS><BS>1<BS>$1.g<CR>/[]<Left>1-5<CR>nnnnnnnnn:s<BS>1,1s/[1-5]/i[]<Left>1-5<Right>/g<CR><Esc>u:s/<BS><BS>1s/[1-5]/$<Left><Left><Left><Left><Left><Left><Left>\(<Right><Right><Right><Right><Right>\)<Right><Right><BS>i\1/g<CR>s/<BS>i<Esc>:2s<BS>,<BS>s/\(1-5<Left><Left><Left>[<Right><Right><Right>]\)/\[<BS><BS>(o\1,i\1)/g<CR>`;<Esc><Esc>:w<CR>:q!<CR>
0 comments