Visual Studio features

Hi,
I was wondering how to get the lightbulb to pop up so i can extract methods. Cant find it on mine. Also, that pop up box that changed both of the ‘NewMethod’ at the same time. neither are coming up on my end.

Cheers :slight_smile:

1 Like

Hi,

Are you using Windows? In which case Ctrl + . is the shortcut to the “lightbulb” quick actions/refactoring menu. (You can also right-click on selected code and the light-bulb should be at the top of that menu).

When you Extract Method in this way you should by default have the Rename pop-up box which lets you change the method name in both places - if you don’t you can press Ctrl + R twice while your cursor is on a method or variable to get that pop-up box to appear and rename it in all places it appears.

I don’t know whether these shortcuts are the same on a Mac, I’d assume so (but with Cmd rather than Ctrl) but can’t confirm.

Thanks for the speedy responce.

Ctrl + space brought up the recomendation bar, And Ctrl r brought up a window to open a file :confused:

Is there a way to make it automatically pop up like it does in the video? That autofill suggestion list doesnt show up on mine eiher

I am on windows BTW :slight_smile:

Sorry, it’s Ctrl + full stop, not a space, so try that one? I’m not sure about the file dialog with Ctrl R - I don’t think that these are any particular Visual Studio extensions/plugins so it should work fine…

Try taking a look in the Edit menu, is there an option for ‘Refactor’? This should tell you what the keyboard shortcut is:
rename

are you using visual studio code? I don’t have most of those options in mine.

Ohh I’m sorry, I’m using regular Visual Studio rather than Visual Studio Code, that explains it.

I’ve just given it a try, looks like Ctrl + full stop still works the same for quick actions, and F2 to change the name of methods/variables (although I can’t get it to show the preview pop-up in the corner).

Sorry again for the misunderstanding!

Thanks for trying :slight_smile:

The Ctrl + . Shortcut is giving me a message “no code actions available” if that helps?

If its not coming up its usually a problem with visual studio not understanding the code so if you press control and . and its not working check the code over as its likely that is the issue.

The lightbulb only appears when it knows it can do something like generate a new method or make an inline variable.
Otherwise if its typed incorrectly it cant suggest anything

Hope this clarifies

@Some-Random

I was reading over your post and wanted to see if i could help with your issue.

  1. You can select all the text you want to extract into a method and right click and you should had a box that says extract method. Then just give it a name.

  2. If its not coming up for you try saving VSC and restart it.

  3. If that don’t work try installing a different version of VS

:slightly_smiling_face:

2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms