Suppose I have a list of strings in a file (a Python script, for example) like this:
my_list_of_numbers = ["one two",
"three four",
"five six",
"seven eight",
"nine ten",
"eleven twelve"]
If I make a visual selection of this text, I can use gq
to wrap the text to get:
my_list_of_numbers = ["one two", "three four", "five six", "seven eight", "nine
ten", "eleven twelve"]
However, the element "nine ten"
is now split in half over two lines.
How do I wrap the text while avoiding entering a newline character inside an open quote? My desired result would look like this:
my_list_of_numbers = ["one two", "three four", "five six", "seven eight",
"nine ten", "eleven twelve"]
I didn't think that there is a reserved command to do this, but we can do it by make it to one line and then by regex, break it to your desired wish.
%s/\(.\{-}".\{-}".\{-}".\{-}".\{-}".\{-}".\{-}\)"/\1\r"/gec
just map the whole thing into a key. so as to make you easy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With