Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio f2 refactor.rename, file.rename

I'm trying to get Visual Studio to Rename a file when I'm in the solution explorer with a file or directory selected and I hit the F2 key. However, I also want Visual Studio to do Refactoring Renaming when I hit F2 and I am in the editor window with my cursor on a variable. I know it is something to do with setting the context of each (Global, TextEditor, etc). However, I can't seem to find the right combination. There is no "Solution Explorer" Context

like image 640
argyle Avatar asked Sep 27 '12 14:09

argyle


1 Answers

Here's what I did in Visual Studio (2013) to get F2 working in the editor and the solution explorer:

  • Go to the Tools/Options menu, and select Environment/Keyboard
  • In "Show commands containing" put File.Rename
  • In "Use new shortcut in" select Solution Explorer
  • In "Press shortcut keys" press F2, and click "Assign"
  • In "Show commands containing" put Refactor.Rename
  • In "Use new shortcut in" select Text Editor
  • In "Press shortcut keys" press F2 and click "Assign"

I couldn't get it to work with "Global". It seems odd to me that this isn't default behaviour, given the ubiquity of using F2 for renaming across Microsoft products, but at least its flexible enough to allow you to set it up.

like image 175
Giles Avatar answered Sep 23 '22 21:09

Giles