Reputation: 52860
I have free text
"starthello","hello
helloInline
helloInline2","hello2","new field"
"not this","no inline line breaks","no","no"
where I would like to join it with "$^ "
to
"starthello","hello helloInline helloInline2","hello2","new field"
"not this","no inline line breaks","no","no"
How can I join inline line breaks in Vim?
Upvotes: 0
Views: 54
Reputation: 7689
You can do this:
:g/[^"]$/.,/"/j
Here's how it works:
:g/ # On every line matching this regex:
[^"]$ # A line that does *not* end with a double quote
/ # Run this command:
., # On every line from the current line until
/"/ # The next line containing a double quote
# Run this command:
j # Join (remove newlines)
Upvotes: 2
Reputation: 1554
There might be other ways to do this, but one way would be to visually select the lines you want to join by pressing Shift+V
and moving cursor up or down. Then pressing Shift + J
to join the selected lines.
Upvotes: 1