Delete characters from the end of multiple lines in VIm

vim

I have code similar to this:

<%= article.body %></td>
<%= article.author %></td>
<%= link_to 'Show', article %></td>
<%= link_to 'Edit', edit_article_path(article) %></td>
<%= link_to 'Destroy', article, :confirm => 'Are you sure?', :method => :delete %></td>

I want to delete the HTML tags from the end of the lines in Vim. The only way I thought of was a search and replace. I know I can insert and append text to multiple lines, but is there a way to delete text from multiple lines?

Best Answer

Search and replace, after '<', a string of characters not (^) the '<' character, until your reach a '>' that is also at the end of the line:

%s/<[^<]+>$//g

Correction:

%s/<[^<]\+>$//g

Related Question