Thursday, August 27, 2009

Reformat multi-line strings along with string delimiters?

I'm a big fan of trying to keep code under 80 columns when programming
so I make frequent use of the 'gqq' command. It doesn't work so well
with the following kind of multi-line string, however, and I find I
have to do formatting by hand more often than I'd like.

Does anyone know of a way to auto-format these lines while retaining
the surrounding quotes, any end-of-line punctuation, and line-
continuation character?

def somefunction():
raise SomeException("This is a long error message that should be
"\
"broken up on multiple lines, but it is output
"\
"somewhere whitespace-sensitive (such as the
"\
"command-line).")

The above example is in Python but the question is applicable to other
languages. In JavaScript for example:

function somefunction():
var somestring = "This is a long error message that should be "+
"broken up on multiple lines, but it is output "+
"somewhere whitespace-sensitive (such as the "+
"command-line)."

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

No comments:

Post a Comment