Reputation: 3219
If I have some html in my editor like this:
<p>Some code here.</p></This needs to be on a new line!>
How do I get the last tag on a new line in the actual editor (not the output)?
Upvotes: 0
Views: 1161
Reputation: 6183
Try something like that:
sed -i 's|\(.*p>\)\(</This.*\)|\1\n\2|g' <your files>
s // substitute
| // begin search
\( // begin group 1
.*p> // search greedy until 'p>' found
\) // end group 1
\( // begin group 2
</This.* // search for '</This' then be greedy until the end
\) // end group 2
| // begin replace
\1 // insert group 1
\n // insert new line character '\n'
\2 // insert group 2
| // end replace
g // global replace for substitute
Upvotes: 0
Reputation: 14870
If you want to put the last closing tag on a new line:
Pattern:
(</[a-zA-Z]+>)$
Replace Pattern:
\r\n\1
Update:
Exact match:
(</This needs to be on a new line!>)$
Upvotes: 2