How can I break long lines when writing c++ code in vim? For example, if I have something like
56 fprintf(stderr, "Syntax error reading recursion value on
57 line %d in file %s\n", line_count, filename);
I get the following compile errors:
:56:25: warning: missing terminating " character
:56: error: missing terminating " character
:57: error: stray ‘\’ in program
:57:37: warning: missing terminating " character
:57: error: missing terminating " character
I'm a vim newbie.
Thanks!
That's not a Vim problem, that's a C problem.
Put quotes at the end of one line and the start of the other. Maybe you're looking for this:
...and if you want to know how to turn one-long-line into two, if you're splitting mid-string, go to where you want to split and then type 'i' followed by quote-enter-quote. Vim will follow your cindent rules when aligning the second line.
Alternatively, maybe it's a view problem? If you have a linebreak in there, it'll give you a compile error. However, in vim it is possible to have it appear to break the line, put
set wrap
andset lbr
in your vimrc file. Check out:help lbr
for info. There's also a way to configure the "leader" on the line, so you know it's a view-only linebreak.Like Billy ONeal, I'm a bit confused why you're asking this as a Vim question. The code you need to write is:
Note that there's no comma - when you remove the extra whitespace, that's just two string literals together. They'll be combined into one, which I believe is exactly what you want.
Put a trailing \ on the end of the line you want to continue.
my advice would be to not break the string -
instead do