Wikia

Vim Tips Wiki

Changes: Delete a pair of XML/HTML tags

Edit

Back to page

(Remove html character entities)
(Change <tt> to <code>, perhaps also minor tweak.)
 
Line 4: Line 4:
 
|previous=1303
 
|previous=1303
 
|next=1305
 
|next=1305
|created=August 11, 2006
+
|created=2006
 
|complexity=basic
 
|complexity=basic
 
|author=bryan
 
|author=bryan
Line 18: Line 18:
 
</pre>
 
</pre>
   
I wanted to just yank the ''at'' text-object instead of visually selecting it, but it seems that the <tt>`[</tt> and <tt>`]</tt> 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.
+
I wanted to just yank the ''at'' text-object instead of visually selecting it, but it seems that the <code>`[</code> and <code>`]</code> 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.
   
 
==Comments==
 
==Comments==

Latest revision as of 06:19, July 13, 2012

Tip 1304 Printable Monobook Previous Next

created 2006 · complexity basic · author bryan · version n/a


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.

CommentsEdit

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

vat<Esc>da>`<da>

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


Around Wikia's network

Random Wiki