emacs-evil/evil-surround

html tags with elements are too "sticky"

jplindstrom opened this issue · 3 comments

Let's say I have this HTML:

some kind of <a href="a">link</a> somewhere

If I do delete surronding tag dst inside "link" to delete the <a> element, that works.

If I now visually select "somewhere" and do st to surround with a tag, and enter "<span", the attributes are remembered and used for the new elemen tag:

some kind of link <span href="a">somewhere</span>

This happens agan if I surround something else. If I add some extra attributes in my new tag, they are added along with the remembered attributes.

Maybe it's related to using e.g. "cst t span" to chang the existing tag to another tag and have the attributes remain (which does sound like a feature, not a bug :) ).

@jplindstrom , I like this feature, to be honest.

Allow me to place a shamless plug here and recommend Exato.el (Evil XML/HTML Attributes Text Object), which allows you to work attributes of html tags as vim objects. It's pretty neat and should help you in a bunch of cases. The source code is here: https://github.com/ninrod/exato.

I'll keep this issue open in case another user wants to chime in with a different opinion.

The way things actually work here doesn't look like it is an intended feature.

If it were a feature, there would be a simple way to not include the attributes, e.g. by adding space after the tag name.

If it were a feature, when you do specify new attributes for a tag, those attributes would override the remembered ones, and would in turn become the remembered attributes to use in the future.

@jplindstrom , I agree with you.

Maybe this behaviour could be "selected" through a specific configuration.

The default should be that tag elements are not sticky.