emacs-evil / evil-surround

you will be surrounded (surround.vim for evil, the extensible vi layer)
Other
627 stars 60 forks source link

html tags with elements are too "sticky" #168

Open jplindstrom opened 4 years ago

jplindstrom commented 4 years ago

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 :) ).

ninrod commented 4 years ago

@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.

jplindstrom commented 4 years ago

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.

ninrod commented 4 years ago

@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.