Visual Studio - Is there a shortcut to insert parentheses around a selection?

前端 未结 3 1302
陌清茗
陌清茗 2021-02-19 03:55

I am playing with Atom and I really like how I can select an expression and press Shift+9 to insert ( and ) outside it. This is convenient

3条回答
  •  不思量自难忘°
    2021-02-19 04:23

    You should check out a third party add-in like Resharper. They bundle a such abilities.

    Resharper

    There is another method noted by @Igor Zevaka.

    Here: Any way to surround code block with Curly Braces {} in VS2008?

    This allows you to create a snippet, and use a shortcut to use it.

    Here is a quick and dirty snippet to do just that.

    To Install:

    Save the code as SurroundWithBraces.snippet into "\Visual Studio Version\Code Snippets\Visual C#\My Code Snippets"

    To use:

    Select block of text. Press Ctrl+K, Ctrl+S Chose My Code Snippets, braces

    
    
      
        
    braces braces Code snippet to surround a block of code with braces Igor Zevaka Expansion SurroundsWith

提交回复
热议问题