4 Answers
4

I believe you can break up long lines with the caret ^ as long as you remember that the caret and the newline following it are completely removed, so if there should be a space where you're breaking the line, include a space. (More on that below).

A caret at the line end, appends the next line, the first character of the appended line will be escaped.
You can use the caret multiple times, but the complete line must not exceed the maximum line length of ~8192 characters (XP/Vista/Win7).

To suppress the escaping of the next character you can use a redirection.
The redirection has to be just before the caret.
But there exist one curiosity with redirection before the caret.
If you place a token at the caret the token is removed.

The empty line is important for the success.
This works only with delayed expansion, else the rest of the line is ignored after the line feed.

It works because the caret at the line end ignores the next line feed and escapes the next character, even if the next character is also a line feed (carriage returns are always ignored in this phase).

The final code block with the line feed example does not display the blank line, even though it is there. (At least it doesn't show up in IE7) Try reformatting using a blockquote instead.
–
dbenhamNov 22 '11 at 23:15

3

The question is, do we should support a bad tool that didn't follow the rules (someone call it a browser, but it isn't) or do you should switch to a browser?
–
jebNov 24 '11 at 12:02

Congrats on the great answer :) I wonder how much longer it will take for my FINDSTR blog to reach 100
–
dbenhamSep 15 '13 at 12:56

(This is basically a rewrite of Wayne's answer but with the confusion around the caret cleared up. So I've posted it as a CW. I'm not shy about editing answers, but completely rewriting them seems inappropriate.)

You can break up long lines with the caret (^), just remember that the caret and the newline that follows it are removed entirely from the command, so if you put it where a space would be required (such as between parameters), be sure to include the space as well (either before the ^, or at the beginning of the next line — that latter choice may help make it clearer it's a continuation).

Examples: (all tested on Windows XP and Windows 7)

xcopy file1.txt file2.txt

can be written as:

xcopy^
file1.txt^
file2.txt

or

xcopy ^
file1.txt ^
file2.txt

or even

xc^
opy ^
file1.txt ^
file2.txt

(That last works because there are no spaces betwen the xc and the ^, and no spaces at the beginning of the next line. So when you remove the ^ and the newline, you get...xcopy.)

For readability and sanity, it's probably best breaking only between parameters (be sure to include the space).