I have this file over here.
<ul class="social-icons">
<li><a href=""><span class="social_linkedin_square"></span></a></li>
</ul>
<ul class="other-icons">
<li><a href=""><span class="other-icon"></span></a></li>
</ul>
I'm trying to only print all the list items in the file using the global command.
(i.e. lines containing <li>...</li>
NOTE: <li>
and </li>
can be on separate lines)
I tried typing this in the command line:
:g/<li>/.,/<\/li>/p
But for whatever reason it's including </ul> <ul class="other-icons">
rather than only the <li>...</li>
lines. Alongside with a range error:
<li><a href=""><span class="social_linkedin_square"></span></a></li>
</ul>
<ul class="social-icons">
<li><a href=""><span class="another"></span></a></li>
E16: Invalid range
Isn't that weird since this global command matches only lines containing <li>
and then the print command runs on each of those lines ending with </li>
so it should stop the match at that same line? What am I missing?
UPDATE: The command works correctly only if <li>
and </li>
are on separate lines which is interesting.
<li><a href=""><span class="social_linkedin_square"></span></a></li> </ul> <ul class="social-icons"> <li><a href=""><span class="another"></span></a></li> E16: Invalid range