Reputation: 353
There is multiple questions closed to this one, but without the same parameters, and I don't find an answer to my problem.
I have a very long long line whitout whitespaces (base64), that I want to break in multiple lines.
Some answers in the site are to use gq, but without whitespaces, it do not work...
Maybe is it another command ?
Upvotes: 1
Views: 446
Reputation: 196876
You can use this command, replacing 10
with the desired width:
:s/.\{10}/&\r/g
It substitutes each group of 10 characters (.\{10}
) with itself (&
) followed by a newline, (\r
).
Upvotes: 2
Reputation: 172758
You can use :substitute
to place a newline character (\r
) into the long line after (\zs
starts the match only there) every N (\{N}
, with g
flag) non-whitespace (\S
; could also simply use .
) characters:
:s/\S\{10}\zs/\r/g
Upvotes: 2