I am using latest available version of NeoVim v0.4.3 and latest Arch build with kernel 5.6.4-arch1-1.
I'm having a problem with the following command in the NeoVim command line:
1 2 3 4 5 6
:g/^$/d | %s/\t//g | %s/ / /g | %s/$/,/ | normal gg | normal 8J
I have introduced spaces between the bar |
so you can see the sequence more clearly.
Note: on the command line, when I run this, the spaces are not there, so it run's Ok in that respect.
Here is what i want to do:
- delete all empty lines. This first bit works as it should.
- delete all tabs in doc. This second bit works as it should.
- replace all double spaces with single space. This bit works as it should.
- place one comma "," at end of each line. The command introduces lots of commas at the end of each line, even though I removed the
g
flag from the:s
command. I only want one comma at the end of each line. - go to the top of the file with the normal command. This bit works fine.
- join the first 100 lines in the file with
8J
. This bit causes the text to become corrupted, and does not appear to join the lines.Ctrl +L
does not fix it.
So parts 4 and 6 don't do what I want them to.
Here is the starting text:
the dog
got up as the
brown fox passed over
this line ... too ... and
another line too
one_more some more
another_too
more information
Here is the text after the command sequence has run up until and including step 4, ie after the end of line $
is replaced with ,
:
the dog,,,,,,,
got up as the,,,,,,,
brown fox passed over,,,,,,,
this line ... too ... and,,,,,,,
another line too,,,,,,,
one_more some more ,,,,,,,
another_too,,,,,,,
more information,,,,,,,
Here is the text if I run all 6 steps of the command as one, as outlined above, from the beginning:
the dog,,,,,,,
rmal 8J
rmal 8J,
rmal 8J,,
rmal 8J,,,
rmal 8J,,,,
rmal 8J,,,,,
rmal 8J,,,,,,
got up as the,,,,,,,
brown fox passed over,,,,,,,
this line ... too ... and,,,,,,,
another line too,,,,,,,
one_more some more ,,,,,,,
another_too,,,,,,,
more information,,,,,,,
How do I get the command in step 4 to parse each line only once and place only one comma at the end of each line?
How do I get the command in step 6 to join all the lines by running J
8 times?