I would like to delete all end of lines (\n) inside a given pattern that
runs through a text. The pattern is like this:
<PubmedArticle>
text1 \n
text2 \n
text3 \n
text4 \n
text5 \n
text6 \n
... \n
<PubmedArticle>
Any help?
IIUC, you want something like
:g/<PubmedArticle>/+,/<PubmedArticle>/-s/\n
which will join all the lines between the two PubmedArticle tags.
I noticed that there doesn't seem to be a closing tag as one
would commonly find in an XML vocabulary...is this intentional?
To help understand that fairly opaque expression, it's of the form
:g/{start regexp}/{action}
where {action} is
{range}s/{thing to replace}[implied "//"]
just as you'd use "1,10s/foo/bar/"...if you don't have any flags,
you can omit the trailing slash, and if you have neither flags
nor a replacement (replace with nothing), you can omit everything
after the search expression (foo).
In this case, the {range} is
+,/<PubmedArticle>/-
which means "from the line following (+) the current line (the
line we're on because of the :g command) through one line before
(-) the next match of <PubmedArticle>" which might more
explicitly be written as
.+1,/<PubmedArticle>/-
(where "." is the current line in the context of the :g command,
and the +1 is explicitly the next line)
Hope this gives you not only some material that might solve the
problem, but a description of how one would generalize it a bit
to troubleshoot any peculiarities you might find when trying to
implement it.
-tim