Carriage return
I have some raw data from terminal output which uses carriege return for formatting. Carriage return sets the pointer to the first character on the line, and subsequent characters will overwrite what was there before. The challange is to simulate the terminal behaviour in vim. I'm kind of unsure if I should have skipped lines 9 and 15, since there might be some interesting solutions which are not that generic. Happy Golfing!
Start file
+--------------------------+ | | | A nice header in a frame +--------------------------+ Emacs rules! Vim A short line Some longer text replacing it +----------------+ | | | Another header +----------------+ Several carriege returns on a line O few A B few more simple ones A two reduce the amount to off specializing the solution of dust for this file j
End file
+--------------------------+ | A nice header in a frame | +--------------------------+ Vim rules! Some longer text replacing it +----------------+ | Another header | +----------------+ A few carriege returns on a line A few more simple ones to reduce the amount of specializing the solution just for this file
View Diff
2c2 < | | | A nice header in a frame --- > | A nice header in a frame | 6c6 < Emacs rules! Vim --- > Vim rules! 9c9 < A short line Some longer text replacing it --- > Some longer text replacing it 12c12 < | | | Another header --- > | Another header | 15c15 < Several carriege returns on a line O few A --- > A few carriege returns on a line 17,20c17,20 < B few more simple ones A < two reduce the amount to < off specializing the solution of < dust for this file j --- > A few more simple ones > to reduce the amount > of specializing the solution > just for this 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.
#20 RobertT / @techrt2050 - Score: 45 - 04/01/14 @ 23:52
/<C-V><CR><CR>qqrRD0@"<Esc>nq3@qnn4@qrRn.FRdtR0@"<Esc>;lD0@"<Esc>ZZ
0 comments
#21 Hugo / @szeyattai - Score: 45 - 08/23/18 @ 02:49
/<C-V><CR><CR>qqrRD0@"<Esc>nq3@qnn4@qrRn.FRdtR0@"<Esc>;lD0@"<Esc>ZZ
0 comments