History Report a problem
Article Edit this page Discussion

Delete a pair of XML/HTML tags

From Vim Tips Wiki

(Redirected from VimTip1304)
Jump to: navigation, search

Tip 1304 Previous TipNext Tip

Created: August 11, 2006 Complexity: basic Author: bryan Minimum version: n/a Karma: 28/10 Imported from: Tip#1304


I've been editing a lot of XML lately and using the new tag text-objects (see :help tag-blocks). The it and at text-objects make it easy to delete/change/yank/etc the content between two matching tags either tag inclusive or not. In my editing I commonly have to remove just a matching pair of tags. Previously I had a nasty function for this which is now replaced with just mapping the following to the key of my choice:

vat<Esc>`<df>`>F<df>

I wanted to just yank the at text-object instead of visually selecting it, but it seems that the `[ and `] marks are cleared when the first edit is made thus making it imposible to just back to the end of the object and kill the closing tag. For large blocks of text using the visual select causes a momentary flicker, but for smaller chunks of content it is not visible.

[edit] Comments

You could also use 'a>' blocks for that:

vat<Esc>da>`<da>

I don't know if use of visual selection could be avoided.


Rate this article:

Share this article:

Hubs Highlights International Sites Wikia messages
Entertainment
Gaming
Cartoons & Comics
Science Fiction
Hobbies
Sports
See all...
Grand Theft Auto
Pixar
Legend of Zelda Wiki
Terminator Wiki
Everquest II Wiki
Flash Gordon
German
Spanish
Chinese
Japanese
More...
Wikia is hiring for several open positions
Send this article to a friend
"Delete a pair of XML/HTML tags"
 
 
Hi!

I thought you'd like this page from Wikia!

http://vim.wikia.com

Come check it out!
Send confirmation


.