dotnet / razor

Compiler and tooling experience for Razor ASP.NET Core apps in Visual Studio, Visual Studio for Mac, and VS Code.
https://asp.net
MIT License
491 stars 190 forks source link

Surround With not available for Blazor component #4433

Open vsfeedback opened 3 years ago

vsfeedback commented 3 years ago

This issue has been moved from a ticket on Developer Community.


I'm trying to apply Surround With to HTML elements and VS says the command is not currently available. I am using latest preview of VS 2022.


Original Comments

Feedback Bot on 7/21/2021, 11:44 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Feedback Bot on 7/26/2021, 03:29 PM:

Thank you for sharing your feedback! Our teams prioritize action on product issues with broad customer impact. See details at: https://docs.microsoft.com/en-us/visualstudio/ide/report-a-problem?view=vs-2019#faq. In case you need answers to common questions or need assisted support, be sure to use https://visualstudio.microsoft.com/vs/support/. We’ll keep you posted on any updates to this feedback.


Original Solutions

(no solutions)

NTaylorMullen commented 3 years ago

More reports:

CarlVerret commented 2 years ago

please bring back this usefull feature !

MattePozzy commented 2 years ago

Any feedback about this?

omuleanu commented 2 years ago

How hard can this be to implement.

dhindrik commented 1 year ago

At least for C# code it must be very easy to fix. So annoying that this not working.

darkkevind commented 1 year ago

Visual Studio 2022 Please can this bee looked in to!? I can use 'surround with' and 'insert snippet' in any .cs file, but not .cshtml, .html or any HTML page!? Why on earth was this feature taken away? 😕

donslattery commented 7 months ago

Another vote to bring this back. You're telling me Elon Musk can land rockets vertically but you can't surround some highlighted code with a user-provided text string? Come on, guys.

danroth27 commented 6 months ago

Hi folks. Just a heads up that Surround With is actually available in .razor files as a keyboard shortcut: Alt+Shift+w. It's just not available as a menu item.

devenv_woWCQeXOBn

Is the keyboard shortcut sufficient?

donslattery commented 6 months ago

Hi folks. Just a heads up that Surround With is actually available in .razor files as a keyboard shortcut: Alt+Shift+w. It's just not available as a menu item.

Is the keyboard shortcut sufficient?

A little bit of an awkward keystroke but I'll take it. Thank you.

Brascal commented 5 months ago

This Alt+Shift+W is a start, but it only surrounds with <div>. I believe what we're all after is a proper surround with that then presents a list of tags that one can use to surround the highlighted text.

danroth27 commented 5 months ago

Thanks @Brascal for this feedback! Please note that after the div is generated it is selected so that you can rename it to whatever element you want, which will rename both the opening and closing tags. I understand this isn't exactly the experience you're asking for, but I want to make sure folks are aware that you can still use Alt+Shift+W to pretty quickly surround content with arbitrary elements.

Brascal commented 5 months ago

@danroth27 you are right! Somehow that capability escaped me; thanks for pointing that out. I was also about to point out that Alt+Shift+W puts the new <div>s on the same line as your selected element, which then requires further manual manipulation to get all three elements on their own line. However I found that if the text selection includes a trailing newline, Alt+Shift+W will place the <div>s on their own lines, as desired.

ryzngard commented 4 months ago

Another note: you can change the shortcut if you prefer. It's set in Tools > Options > Keyboard like this

image

vierlijner commented 2 months ago

Hi folks. Just a heads up that Surround With is actually available in .razor files as a keyboard shortcut: Alt+Shift+w. It's just not available as a menu item.

devenv_woWCQeXOBn devenv_woWCQeXOBn

Is the keyboard shortcut sufficient?

Why not "Ctrl+K, Ctrl+S" to keep it in style with the others?

vierlijner commented 2 months ago

And this only works in the HTML part, not in the code block. So I have to put the c# code in a file behind, to make use of a surround (with).

davidwengier commented 2 months ago

As per the screenshot above, the "surround with" that is available in .razor files, in Html, is actually the "Wrap With Div" command from Html. Alt+Shift+W is the default keybind.

Ctrl+K, Ctrl+S is Edit.SurroundWith, which is for a specific type of snippet, and has a custom UI in VS that is not currently available with the technology that the Razor editor uses. This issue is tracking that latter piece.

zorgoz commented 2 months ago

Huge Up for this last comment, as it clarifiers the differences between the two. I don't see how the "surround with element" got here. The issue I am facing too is related to the c# code sections, not the html markup. Actually, they should have been addressed with the same feature/widget just context sensitive. But currently these two are different things for whatever reason. And I am really missing it in the code sections. Made report too. The fact that this is such an old or recurring issue is just annoying.