print("This is 1.\n");print("This is 2.");
print("This is 3.\n");
I would like the above to be formated like (which is just adding in the
newline a print that may not have it, but only if it does not have it):
print("This is 1.\n");print("This is 2.");
print("This is 3.\n");
I presume you mean that second section to read
print("This is 1.\n");print("This is 2.\n");
print("This is 3.\n");
adding in that "\n" after "2."
On the assumption that you don't have quotation-marks escaped in
your strings such as
print ("She said \"hello\" to me");
you should be able to do something like
%s/print\s*(\s*"[^"]*\(\\n\)\@<!\ze"/&\\n/g
which should catch most of the non-pathological cases. If quotes
can span lines, such as
print ("this is a
really long string")
then you can change
[^"]*
to
\_[^"]*
HTH,
-tim