Svisstack
Svisstack

Reputation: 16656

Shortcut in Visual Studio 2010 to generate all possible Case's in Switch

I can't find key binding to expand all possible cases in switch, eg. have switch with enum argument, in Borland C++ i doing this with TAB key while switch code is selected.

I want to do this in Visual Studio 2010.

Can anyone help me?

Upvotes: 7

Views: 7681

Answers (3)

Oleksandr Martysh
Oleksandr Martysh

Reputation: 190

I often use Switch with enums. JaredPar's answer is good, but it doesn't work for me (possibly because i am using ReSharper).

What is working for me: after creating a Switch statement based on some enum, i click my mouse at begining of word "Switch", then i press ALT+ENTER and select "Add switch statement for bla-bla-bla...". This will generate all cases for all possible enum values.

Upvotes: 0

silver
silver

Reputation: 1703

I had the same issue and it was duo to resharper installation which does it differently.

after entering the switch and the parameter place the curser in the switch body and then you need to click on the lamp icon on the left or clicking Alt+Enter.

Upvotes: 0

JaredPar
JaredPar

Reputation: 755259

It C++ it's not possible to do this. The IDE just doesn't have support for that operation.

In C# you can do this with the switch code snippet:

  • Type "switch" in the IDE which will select the snippet in intellisense
  • Hit Tab to insert the snippet which will move the cursor inside the parens
  • Type the expression to switch on and hit Enter

This will expand out the known cases into the IDE.

Upvotes: 16

Related Questions