This sounds like a very basic question that probably has an obvious solution, I haven't found it, unfortunately.
How do I keep vim from breaking (entering a newline) in the middle of a string? I type in a list of strings, and it looks like this:
a=['a string', 'b string', 'c
string']
I like the line breaks, I don't want vim just to wrap the line and continue on the next editor line. I want my lines to be roughly 80 characters long without manually entering newlines.
What I want is either
Don't break any string, even if it has a whitespace
Break the string using implicit string concatenation, i.e. close the string and start a new string on the new line
The closest solutions I have found are not very useful:
Is there any way to get vim to auto wrap python strings at 79 chars?
how to configure vim to smartly wrap python strings?
Vim: Inter-String Line Breaking
Currently 'J' is one of the most heavily used keys to fix broken strings.
Here is what I do to wrap all lines at 80 characters without breaking any words, and preserve shorter lines:
:set formatoptions+=w
:set tw=80
gggqG
You can also use the following mapping to format current paragraph:
:nnoremap Q gqip
hope it helps.
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