May 11th, 2023
heart7 reactions

Surround selection experiment

Principal Product Manager

You want to quickly select some text and surround it with quotation marks. So, you select your text and hit the quotation mark key on your keyboard, only to find that the selected text now has been replaced by a single “. What you hoped would happen was that the selected text would be surrounded by an opening and closing quotation mark like in the animation below. Let’s do something to fix this.

Image Surrounder2

In this experiment, we want to test if we can create a general feature for all languages that makes it easy to surround the selection. In fact, multiple developers have requested this feature, so remember to vote for it if you agree.

Our hypothesis is that a feature like this is language agnostic and doesn’t need to be customized per language. But we need your help to help test that hypothesis and, potentially, help improve the feature design. We’ve created an extension for Visual Studio called Surrounder that we’ll be using for this experiment.

The extension is very simple to use. Any time you have a selection and type one of the supported characters, the selection will be surrounded by that character and its closing equivalent, as shown in this table:

Opening Closing
` `
( )
[ ]
{ }
< >

 

To participate in this experiment, install the Surrounder extension and let us know how it works for you. Either by commenting in this blog post, or by opening issues or pull requests on the GitHub repo.

There is currently an open feature request for us to implement this behavior in Visual Studio, so make sure to go vote for it.

Author

Mads Kristensen
Principal Product Manager

Mads Kristensen is a Principal Product Manager at Microsoft, working to enhance productivity and usability in Visual Studio. He’s behind popular extensions like Web Essentials and File Nesting and is active in the open-source community. A frequent speaker, Mads is dedicated to making Visual Studio the most enjoyable IDE for developers.

15 comments

Discussion is closed. Login to edit/delete existing comments.

Sort by :
  • Joshua Laquai

    How is this an “experiment” when VSCode has had this feature since the beginning of time and!?
    And as @reduckted already mentioned, AutoSurround has been available for VS for ages AND it’s so far ahead of… whatever this is.
    Stop trying. Accept you’re years late to the party and stop trying.

    • Mads KristensenMicrosoft employee Author

      From the third paragraph:

      > Our hypothesis is that a feature like this is language agnostic and doesn’t need to be customized per language. But we need your help to help test that hypothesis and, potentially, help improve the feature design.

  • Eli Black

    As long as there’s a setting to enable/disable this, I’m all for it! 🙂

    I’m not a fan of this feature, but I know this has become standard in most other editors, so making it be the default in VS probably makes sense, too! 🙂

  • Andreas Saurwein

    Great feature – at least 10 free extensions already do that. Is it really required to add this now to VS? It feels like VS is trying to catch up with VS Code. Adding more and more features that break existing ones.

    Besides, this kind of features have a negative influence on the extension economy. There are many extensions that are cheap but lost their right to exist because VS after 20 years finally can do it too.

    • Mads KristensenMicrosoft employee Author

      Features first found in extensions sometimes become industry standard in editors and IDEs. At this point, there is an expectation from users that these features are found natively in Visual Studio or whatever their tool of choice might be. We don’t want to discourage extension authors (believe me, I’m one myself), but expectations, use cases, and competitive landscapes change over time, and we must all adapt.

  • Viacheslav Ivanov

    Nice thing!

    I’m expecting an escaped double quote inside a string literal in C# so for me this feature should be language specific:

    var text = $"User {userName} not found.";

    “{userName}” is selected and double quote pressed

    var text = $"User \"{userName}\" not found.";

    Instead, it would make sense to allow pressing other characters, including backslash, while Alt or Shift pressed, so the user can type escape symbols.