Is there a Visual Studio keyboard shortcut to rename a file in Solution Explorer? - visual-studio

As the question title says: Is there a Visual Studio keyboard shortcut (or series of shortcuts) to rename file in Solution Explorer?
I am using VS2008 and manually doing this by right-clicking on a file in the Solution Explorer and selecting 'Rename', but this is a pain in the behind.

Depends on your settings profile:
In the C# profile, F2 does this.
you can assign a shortcut to any key:
Tools -> Options, Expand Environment and select Keyboard
Enter File.Rename into the text box
Put the Focus on the "Press Shortcut keys" box and hit 'the key you want to assign'
Click Assign

No use option Refractor.Rename and Assign key to that say F2

Use: File Utils Extension
command T or control T >File Utils: Rename, that's it.

Related

Is there a way to set a keyboard shortcut to open containing folder of a selected file in Solution Explorer in Visual Studio?

When I click on a C++ project in Visual Studio, I get this menu:
And so I can quickly press Alt+F,F(Command ProjectandSolutionContextMenus.Project.OpenFolderinFileExplorer) to open the folder of the project.
I also found that I can open containing folder if I open the file in the Text Editor in Visual Studio:
I bound it to Alt+F,F as well. I set it to only be active in Text Editor, it's the File.OpenContainingFolder command.
But when I click on files inside the project in the Solution Explorer, there is no context menu:
I tried to make the File.OpenContainingFolder command global, but it still doesn't work in the Solution Explorer when I just click on a file once. If I double click it and open it in the text editor, it works.
And I can't find a command in the Keyboard section in options of Visual Studio to open containing folder of a file selected in the Solution Explorer.
Maybe someone knows how to do it?
You can create an external tool menu item, and then bind a shortcut to that item.
Go to Tools > External Tools.
Click Add.
In Title edit box type Show in Explorer.
In Command edit box type explorer.exe.
In Arguments edit box type /select, $(ItemPath). There is a space between a comma and a dollar sign.
Click OK.
Make note at the position of the new command in the list. It could be first, it could be fifth, or something else. Let's assume it's the fifth one.
Assign a shortcut to the command Tools.ExternalCommand5. Restrict the shortcut to Solution Explorer.
That's it.

Shortcut in Visual Studio to open solution in Windows file explorer?

Is there a keyboard shortcut in Visual Studio (currently using 2013) to open the solution (or a project) in the Windows file explorer?
Currently, I normally have to open up the Solution Explorer, right-click on my solution or a project and scroll down to 'Open Folder in File Explorer', but this becomes a time consuming task as I have to do it often (TortoiseGit not integrated with my IDE).
An improvement over #Walt_Ritscher's answer I found was to assign a keyboard shortcut to the File.OpenContainingFolder.
Instead of having to first select a project or solution from the solution project I can simply press a desired keyboard shortcut while any file is in focus (without having to open the Solution Explorer) and it will open the file location in Windows Explorer. This saves time if the focus in my solution explorer is on a file deep in the structure of my solution explorer since I don't have to scroll all the way back up to select a project/solution before hitting the keyboard shortcut.
Yes, you can add your own keyboard shortcut to open the folder.
Open the Tools/Options/Keyboard dialog. In the Show Commands Containing textbox, type OpenFolderIn and you will see the OpenFolderInFileExplorer command. Select the command, then assign a shortcut key. Move your cursor to the Press shortcut keys textbox.then press your desired key combination. In my example I chose Ctrl+Shift+'. Be sure and click the Assign button to memorize the shortcut key
Press OK and you're done.
For visual studio vs2017:
Ctrl+Shift+Alt+O

Visual Studio: Shortcut to close window not working

I changed the shortcut to close a window to Ctrl+W and to close all windows to Ctrl+Shift+W. Close all windows works fine, but Ctrl+W selects the word currently under the cursor but does not close the window.
When I right-click a tab it say Ctrl+W is the shortcut to close it (And also Ctrl+S to save and Ctrl+Shift+W to close all). Why is only the close window shortcut not working?
In Visual Studio (VS 2015 in my case but it's similar down to VS 2010 at least) keyboard shortcuts may have a different meaning depending on the context in which they are executed.
Click Tools / Options / Environment / Keyboard to look up or define shortcuts (you already did that probably). What I called "context" is selected in the combobox labelled "Use new shortcut in:". Most likely you defined the shortcut in "Global" but you want it to work in "Text Editor". In the latter Ctrl+W selects the current word.
Redefine Ctrl+W for "Text Editor" and you should be fine.
I am using Visual Studio 2017 & Visual Studio 2019 and tried the answer from #TobiMcNamobi but it didn't work for me. After few such tries I got it work with below steps.
You should add it as Global shourtcut otherwise it will not work for Designer views.
Add CTRL+W as a Global shortcut for Window.CloseDocumentWindow
Remove the CTRL+W shortcut for Edit.SelectCurrentWord
In Visual Studio 2019 it is Ctrl-F4 by default to CloseDocumentWindow. The action is Window.CloseDocumentWindow. I know this is old but the accepted answer has you change the short-cut key instead. I would rather use the default option.
Tools -> Options -> Environment -> Keyboard
If you're ever unsure go to the path above and you will see the image above then you can click inside the box "Press shortcut key" at the bottom of the form and type the short cut key you're interested in and it will tell you if it is used and what it is currently used for.
You can also reference the docs
https://learn.microsoft.com/en-us/visualstudio/ide/default-keyboard-shortcuts-in-visual-studio?view=vs-2019
2021: For Visual Studio 2019:
See: https://gist.github.com/jpoehls/2030795#gistcomment-2335647
In my case, I had to existing assignments that I had to remove. Thereafter, I could use the hotkey.
In my case, the tabs were not closing because I am using Vim extension. I had to add the following lines to Vim settings:
"vim.handleKeys": {
"<C-w>": false
}
Just press Ctrl + , or Command + , for Mac users, search for Vim and go into Edit in settings.json as the following picture shows:
Screenshot
For Visual Studio 2022, make sure you also remove Ctrl+W from selectCurrentWord command.
In my VS Pro 2019, on Tools / Options / Environment / Keyboard, the first line offers using a premade keyboard mapping scheme, with a drop-down option for VSCode keyborad mapping theme.
I picked it and it seems to have adopted the keyboard shortcuts I was used to from working on VSCode, Ctrl+W included.
For those using linux with VSCode v1.56.2,
File --> Preferences --> Keyboard Shortcuts.
Search for View:Close Editor and as mentioned above, remove any keybinding that has the keybinding you want.

How to Restore Navigate To Dialog in Visual Studio After Resharper Installation

After installing Resharper 7.1.2 for Visual Studio 2010, when I press Ctrl+, I no longer see the Navigate To dialog. Instead a Resharper dialog Recent Files appears. My question is, is there another key binding that I am not aware for the Navigate To dialog or how can I configure Resharper/VS to show the Navigate To dialog upon pressing Ctrl+,. In the Resharper options I have selected Visual Studio for the key bindings since that is what I am accustomed to, but for some reason this one has changed.
It sounds like you will need to remove the ReSharper keybinding and add the Visual Studio one again. Try the following:
From Visual Studio 2010, go to Tools -> Options -> Environment -> Keyboard.
In the textbox below "Show commands containing:" enter "gotorecent".
This should bring up one match and you can see the Ctrl+, shortcut applied:
Click the Remove button. This should remove the keybinding.
In the textbox below "Show commands containing:" enter "edit.navigateto" (or for VS2017 "edit.gotoall").
This should bring up two matches. We are only concerned with the first one so make sure it is selected.
Click the texbox below "Press shortcut keys:" and press Ctrl+,
Click the Assign button.
Click the OK button.
You may have to restart Visual Studio but that should do it.
Edit: Just in case it helps anyone else, in order to track down the command names, I exported the keyboard settings via Tools -> Import/Export settings -> Export selected environment settings -> select only Options -> Environment -> Keyboard.
In the resulting .vssettings file, the Command attribute of each Shortcut element contains the text that should be typed into the "Show commands containing:" textbox.
It should be noted that the command for ReSharper's navigate to dialogue is "Ctrl + T"
In Visual Studio 2017, you need to assign Ctrl+, to Edit.GoToAll (rather than Edit.NavigateTo).
UPDATED:
Go to the Options->Environment->Keyboard, Make sure that (Default) is chosen in the top dropdown, type in Edit.GoToAll in the "Show comands..." textbox. Remove the existing shortcut. Type Ctrl+, in the "Press Shortcut Keys:" textbox. Click assign.
#Malice explained really well, but here is just one more tip:
When you are in the Keyboard Options menu, you don't need to export all commands in order to see which command corresponds to a particular shortcut, you can click on the "Press shortcut keys" text box and type your keyword to see what it is assigned to.
So you could:
go to the Keyboard Options menu,
type Ctrl+, to see what it is assigned to,
unassign it,
then type Ctrl+T to see what that "Navigate To" dialog is called within VS
reassign that function to Ctrl+,

Visual Studio Sourcesafe 6.0 *.js filetype change default editor

I'm using Microsoft Visual Studio Sourcesafe 6.0.
When edit *.js(JavaScript) File Type, the default text editor is notepad.exe, but I want to use another text editor.
How to change *.js File Type default text editor?
By default, you can use notepad to view JavaScript source code. To change it, follow these steps:
Quit Internet Explorer (if it is running).
Double-click My Computer.
On the View menu, click Options (or Folder Options).
Click the File Types tab. In the Registered File Types box, find JavaScript, click it, and then click Edit. Then select your editor.
Note: If it is not works, you may need to type a space and %1 at the end of the command. For example, if you want to use Notepad to be your default HTML editor, type the following command: c:\windows\notepad.exe "%1"
OK, click Close, and then click Close again.
Reference: http://support.microsoft.com/kb/163606/en-us
Does it really work? I don't know. But try it, please.
this can be easily done via Tools->Options menu in Visual SourceSafe Explorer. How to: Change the Default Editor

Resources