Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Treat self-closing XML/HTML tags as <> #376

Closed
ebrannin-bw opened this issue May 12, 2023 · 5 comments
Closed

Feature request: Treat self-closing XML/HTML tags as <> #376

ebrannin-bw opened this issue May 12, 2023 · 5 comments

Comments

@ebrannin-bw
Copy link

Steps to reproduce

  1. Make a new document:
<outer>
<inner />
</outer>
  1. Put the cursor in the middle of <inner />: /inn
  2. Type ysat<middle> (not shown below) or ``ysatmiddle>` (shown)

Expected result:

<outer>
<middle>
  <inner />
</middle>
</outer>

Observed result

<middle>
  <outer>
  <inner />
  </outer>
</middle>

Workaround

ysa<<middle> or ysa<<C-T>middle>

Background

Self-closing tags come up in HTML5, XML, React, etc.

I was just turning a React component from a flex-row into a table, and as I wrapped each element with <td> I had to switch between ysat and ysa< depending on if it was self-closing or not.

@tpope
Copy link
Owner

tpope commented May 15, 2023

I think I agree. However, surround.vim is merely delegating to Vim's built-in at operator. You can see the same behavior if you do dat or gUat.

And I don't plan on breaking with Vim here. You could try floating your proposal to Vim itself, but I doubt it would be considered due to backwards compatibility concerns.

@tpope tpope closed this as completed May 15, 2023
@ebrannin-bw
Copy link
Author

Makes sense, thanks!

@ebrannin-bw
Copy link
Author

Looks like vim has already documented this:

"<aaa/>" items are skipped. Case is ignored, also for XML where case does matter.

Sounds like what I really want is a custom text-object plugin to declare something like aT and iT (or whatever, but it seems like those aren't built-in) -- I'll update here if I find one already exists or (very eventually) figure out how to write one.

@tpope
Copy link
Owner

tpope commented May 15, 2023

Sounds like what I really want is a custom text-object plugin

Yes, but see #355.

@tpope
Copy link
Owner

tpope commented Jun 2, 2023

Oops, I meant to link to #329 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants