Search code examples
visual-studio-2010keyboard-shortcutshotkeys

add try catch around highlighted code


I'm refactoring some code and there are tons of functions with no try catch statements that are causing problems.

Is there a keyboard shortcut in VS 2010 to allow me to select an entire function or highlighted code and add a try catch end try statement around it...with the highlighted code automatically ending up under try ?

Just looking for a shortcut


Solution

  • I'm not aware of a keyboard short-cut, but there's a right-click available.

    • Highlight the code for your try block.
    • Right click and select
    • "Surround with..." Scroll down the selection until you see the "try" snippet label.
    • There you go!

    Hope this helps!

    I'll dig around to see if there's a keyboard short cut for this. There probably is -- there's hundreds of them.

    UPDATE: Looks like the keyboard shortcut is Ctrl + K, Ctrl + S.