I know that Visual Studio has some tools for fast surrounding by code snippets, for example how to do more faster try/catch code blocks. but I can't find a hotkey combination to do this. Who knows the hotkey combination for try/catch?
Asked
Active
Viewed 2.6k times
46
-
1type "try" then tap Tab,Tab – sa_ddam213 Nov 28 '12 at 09:43
-
1@sa_ddam213: That doesn't surround the currently selected code with try catch. – Daniel Hilgarth Nov 28 '12 at 09:43
-
1– Daniel Lane Nov 28 '12 at 09:44
3 Answers
106
Press "Ctrl + K, S" and then in drop down menu double click "try" - it's a "try-catch" template.

Sasha
- 1,676
- 1
- 16
- 18
-
7
-
8Here's a rather inappropriate tip to help remember this shortcut: KS (kamasutra) is a rather popular condom brand in India. Whenever, you need to "surround" something...ahem..you just use ctrl + K,S – arviman Sep 09 '15 at 10:04
-
3Although in spirit correct its `ctrl + K, ctrl+S` if you do that combination VS would not recognize it. This is more to the point: [link](https://stackoverflow.com/a/13602070/1242782) – apereira Jan 25 '18 at 14:42
-
2A more appropriate way to remember this shortcut is that it takes you to the *K*eyboard *S*hortcuts – cstrutton May 01 '19 at 15:03
-
@Habib, what if i want to add try-catch directly without selecting any line, like before typing some code, is there any short cut in this case?? – Vivek Thummar Oct 29 '21 at 10:18
-
-
28
Try Ctrl + K, Ctrl + S.
Source

Daniel Hilgarth
- 171,043
- 40
- 335
- 443
-
2if i could double plus 1 you i could!! i tried the `ctrl + K, S` and always lost my code, I kept banging my head until I read you post.... – apereira Jan 25 '18 at 14:38
-
1Ctrl + k, Ctrl + s worked in my VS2022, rather than Ctrl + k, s – AverageHomosapien Sep 22 '22 at 08:54