Also asking how to apply an ex range to a normal command.
In a file of some 125k lines with a preamble followed by 8 columns of 10 character wide text, the contents of the column are 8 characters of numbers followed by spaces, except that the last column has no trailing space.
If I wanted to wrap it such that each column becomes a row in order,
I would set tw=9
(or 8 or 10?) and then use gq
to wrap it.
I hoped the easiest thing to do would be to go to the first line after the preamble and type something like:
:.,$gq
As you know, gq
is not an ex mode command.
I couldn't find in the help where the ex mode version of a formatting command is, I'd love both an answer to if that does exist what it is, or if it doesn't, and what you'd do to apply the gq normal mode command to everything to the end of the file. Is there something better than type:
200000gq
?
EG file:
These are very nice data points from our experiment.
This was carried out at our big data point lab by [email protected]
If you positioned your cursor on the fifth line, what would you
type in vim to turn all of these points into their own line?
1 10 100 1000 10000 100000 1000000 10000000
10000001 10000010 10000100 10001000 10010000 10100000 11000000 20000000
... 125k lines later
88888881 18888818 18888188 18881888 18818888 18188888 11888888 28888888
Where the desired format would be:
These are very nice data points from our experiment.
This was carried out at our big data point lab by [email protected]
If you positioned your cursor on the fifth line, what would you
type in vim to turn all of these points back into columns? [BONUS]
1
10
100
1000
10000
100000
1000000
10000000
1.25M lines of data points; Padding or alignment aren't important now.
:.,$norm gqq
but it only does about half of the lines, and I had to repeat this a lot.:.,$!grep -oP '\w+'
is probably faster.gqG
should work too (but it will take some time...). Bonus ::.,$! fmt