visual-studioidevisual-studio-2022code-editor

How to wrap selected code in brackets/parentheses in Visual Studio 2022


In VS Code and JetBrains IDEs, when you select (highlight) a snippet of code and press an opening key for brackets ({ or [) or parentheses ((), it wraps the selected text. Visual Studio, however, deletes the selected snippet, or better, replaces it by the pressed character. Is there a way to configure it to the more intelligent behaviour of VS Code and JetBrains? I browsed "Text Editor" settings but didn't find any that seemed to do this: enter image description here


Solution

  • Tools -> Options -> Text Editor -> General: Automatically surround selections when typing quotes or brackets enter image description here