Visual Studio shortcut for opening command prompt in current project path - visual-studio

On a keyboard shortcut, I want to be able to start the Windows command prompt with the working directory set to the current project directory selected in solution explorer (or text editor). Unfortunately, I am unable to find an appropriate keyboard shortcut in the Visual Studio settings.
Is such a thing possible inside Visual Studio and Visual Studio Code? And if so, how can I set it up?

Sure this is possible!
Configure an external tool
You have to set up a custom external tool. For that, go to Tools > External Tools... and click Add and configure the tool like this:
Setup the keyboard shortcut
Next, you want to bind a shortcut to that external tool. For that go to Tools > Options > Environment > Keyboard and bind your desired shortcut to Tools.ExternalCommand1. Make sure you have moved the external tool to the first position in the window shown above.
Additional Information (For Visual Studio Code)
To Open New Command Prompt use Ctrl+Shift+C to perform same action
named workbench.action.terminal.openNativeConsole

Related

Make Visual Studio use VS code shortcut keys / key bindings

I've been using VSCode a lot lately and have gotten used to the keys-shortcuts/key-bindings (Ctrl+D, Ctrl+P, Alt+leftArrow, etc). However I've recently had some work where I needed to use regular Visual Studio (Microsoft Visual Studio Enterprise 2019) and it's painful remembering two different shortcut keys.
Is there a way to import VSCode key-shortcuts to into regular Visual Studio?
I've looked at this question and there wasn't much help besides manually changing them one at a time.
UPDATE: now the above post answers the question now that I posed Francois du Plessis's answer there.
If you go to Tools -> Options -> Environment -> Keyboard. There should be an option to select Visual Studio Code as a Keyboard mapping scheme
You can create your own settings file based on an existing Visual Studio file.
Simply add your settings to it from VSCode keybinding setting file.
VSCode's keybinding settings is stored in keybindings.json json-formated file.
open file in menu
File->Preferences->Keyboard Shortcuts
or on Windows file path like that
C:\Users\<user name>\AppData\Roaming\Code\..\keybindings.json
Visual Studio's keybinding settings is stored in CurrentSettings.vssettings xml-formated file.
on VS menu:
Tools->Import and Export Settings
then select 'Import select environment setting' radiobutton and click 'Next'
you'll see browser for import your file.
on Windows file path like that
C:\Users\<user name>\Documents\Visual Studio 2019\Settings\
You can read more about it at this:
Make Visual Studio use VS code shortcut keys/key bindings

Go To File and Go To Member - de/select Current Document automatically in Visual Studio 2017

I'm trying to wean myself off DPack for navigation because the new Go To feature is great. However, when Current Document is selected, Go To File doesn't work.
What I'm looking for is:
have Go To File (Ctrl+T > f MyFile.cs) work even with Current Document selected (or automatically deselect it)
have Go To Member (Ctrl+T > m MyMember) automatically select Current Document
or customize the Ctrl+Alt+C shortcut to be less cumbersome.
Are any of those possible?
Based on answer from Sergey Vlasov
Install Visual Commander extension to Visual Stuido
Open Visual Studio and go to menu VCmd / Import...
Import Go to member and file commands file
Imports GoToMember and GoToFile commands
Go to menu Tools / Options, open category Environment / Keyboard
Search for VCmd
Assign keyboard shortcut to VCmd.Command01 (belongs to imported GoToMember command)
You can use Alt+\ which is also used by ReSharper, which does same thing.
Assign keyboard shortcut to VCmd.Command02 (belongs to imported GoToFile command)
You can use Ctrl+T or Ctrl+, to override default GoToAll from Visual Studio
Profit!
You can control the Current Document option with my Visual Commander extension. See Go to a member in the current document and Go to a file in the solution commands.

How do I add a default Run As Administrator when I open a sln file from the command prompt or Windows 7/8 Jump List menu?

I have been researching around the web trying to figure out how to add Run As Administrator as the default menu item for a Visual Studio solution when you:
right-click the solution in Windows Explorer
right-click on a pinned application, such as Visual Studio 2013, to bring up the Jump List and then select the solution
The instructions that I have found so far:
http://www.howtogeek.com/howto/windows-vista/add-run-as-administrator-to-any-file-type-in-windows-vista/
show how to easily add the Run As Administrator menu item to an existing file type. You just have to find the right registry keys for the Visual Studio version that you're working with. For example, Visual Studio 2013's registry key for its solution file type is:
[HKEY_CLASSES_ROOT\VisualStudio.sln.12.0]
Then you just copy the Open command under the shell key, then paste it in as a new key whose name is runas.
After that change, when you right-click on the solution in Windows Explorer, Run As Administrator is in the list of commands. But it is not the default.
To open the solution as Administrator from the Jump List menu, when you right-click on Visual Studio as a pinned icon, you have to right-click on the solution file in the Jump List, then select Run As Administrator.
But I couldn't find anywhere about how to make the Run As Administrator the default command in this menu.
So how do you do that?
Easiest way is doing this:
Right click visual studio and open file location.
(If it's the shortcut, right click then click properties. On the bottom click on "Open File Location")
This should lead you to devenv.exe.
Right click this and select troubleshoot compatiblity.
Select troubleshoot program and check off the box for "The program requires additional permissions" and select next.
Now if you open visual studio from where ever, it'll open it as an administrator.
It actually turns out to be one additional registry entry that needs to be set. In the shell key under the file type, change the value of (Default) to be the same name as the command in the registry under the shell folder.
For example, to set Run As Administrator to be the default, you would set the value of (Default) in HKEY_CLASSES_ROOT\VisualStudio.sln.12.0\shell to be runas.
When exported, this setting looks like this:
[HKEY_CLASSES_ROOT\VisualStudio.sln.12.0\shell]
#="runas"
Now when you right-click the solution in Windows Explorer, or when you right-click the solution after right-clicking to bring up the Jump List on the Visual Studio 2013 pinned icon, Run As Administrator is the default command instead of Open.
So you can confidently open the solution itself from Windows Explorer or the Jump List menu and watch as Visual Studio opens as Administrator.
Updating answer for Visual Studio 2015 (under covers version "14.0"). Tested on on Windows 10 Pro v1703 Creators Update. Picture below illustrates the first registry change. Second change goes one better - no need to right-click the jump list item at all.
Windows Registry Editor Version 5.00
;To add "Run As Administrator" to Visual Studio 2015 Taskbar Jump List solution right-clicks
[HKEY_CLASSES_ROOT\VisualStudio.sln.14.0\shell\RunAs]
[HKEY_CLASSES_ROOT\VisualStudio.sln.14.0\shell\RunAs\command]
#="\"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\devenv.exe\" \"%1\""
;To make Jump List solutions open As Administrator by default
[HKEY_CLASSES_ROOT\VisualStudio.sln.14.0\shell]
#="runas"

Moving from Visual Studio to Sublime Text

I'm working with Sublime Text for a while now and it works perfectly! But at my new work they're using Visual Studio, with some plugins and shortcut changes I'm now be able to work a little bit faster but I prefer Sublime Text.
Why I'm stuck to Visual Studio at my work is because of 3 things:
1. TFS: Team Foundation Server
I've found the Sublime TFS plugin, I haven't tested it yet but I think it works the same as the Sublime SVN plugin which I don't like (no status on checkout, just waiting until it's done). For SVN I'm using TortoiseSVN which works nicely. Is there something like TortoiseSVN for TFS?
2. Solutions
If I browse to the solution/product folder on my computer, add a new file and go back to Visual Studio I've to include that file into the solution/project. I'm used to exclude files which I don't like to use in my project instead of include. Is it possible to change this?
3. Build system
After every change I've to build. Instead of just save (F5) and go to my browser (ALT-TAB) which refreshes automatically after every change, I have to save (F5), build (SHIFT-F6), go to my browser (ALT-TAB) and refresh (F5) with Visual Studio. I'm pretty handy with it now, but I think this can be done easier. So is it possible to build automatically after saving?
What I did until now is searching on Google. I've found some interesting things but nothing which covers these 3 things. For example; here a simple tutorial for the build system. I hope someone can help me out with this so I can say good bye to Visual Studio and return to Sublime Text with love.
I have setup a shortcut key in Visual Studio to open my files in Sublime Text Editor. Below is a step by step guide to doing this.
Step 1:
Open Visual Studio, Go to "Tools" menu and Select "External Tools..."
Step 2:
Click on "Add". Set up a Title say "Open in Sublime" , browse to "sublime_text.exe" to the set the Command textbox. For the arguments fill them with $(ItemPath):$(CurLine):$(CurCol) - this will tell Sublime to open the Visual Studio's current file and go to the same location within that file. Set the Initial Directory to $(ItemDir).
Step 3:
Now if you go Menu > Tools you will find our newly added "Open In Sublime" option. Now let's take this one step forward and setup a shortcut key for this.
Step 4:
Go to Menu > Tools > Options, Under Environment select "Keyboard". In the "Show command containing:" field search for "externalcommand6" and press in your shortcut key combination you want to assing and click the "Assign" button. Avoid combinations that are already in use.
That's it you're done
Sublime text editing is now just a keystroke away.
You can use them both. Visual studio is an ide and manages a lot more then just editing the text files.
If you want to use your text editor of choice you just need to get familure with the command line tools that VS hides from you.
For TFS tasks you need to use TF
When you need to build just invoke MSbuild which is what Visual Studio more or less does anyway. You can also edit the project files by hand as there just msbuild files.

Blame source file from within visual studio

I'm using AnkSVN within Visual Studio 2010, and it covers ~95% of my SVN needs. The biggest missing feature is that I can't find a way to blame a file from directly within VS. The workaround I currently use is to right click on the file within the tablist, and select Open Containing Folder, and then right clicking on the file in Explorer to call Blame.
It's called Annotate in AnhkSVN.
Subversion -> Annotate in the context menu.
I didn't like AnkhSVN's Annotate feature. So I used the following:How to integrate TortoiseSVN into Visual Studio.
Content from above url:
If you're using Visual Studio, you can integrate TortoiseSVN commands to various context menus.
The first step is to add the TortoiseSVN commands as external tools, under the menu TOOLS->External Tools....
Add the name of the command, the path to TortoiseProc.exe and then the parameters for the command.
Use the VS variables wherever needed. Since I add my commands to the context menu of the open file tab, here's the parameters I used:
/command:blame /path:"$(ItemPath)" /line:$(CurLine)
/command:diff /path:"$(ItemPath)"
/command:log /path:"$(ItemPath)"
Notice the /line: parameter: this will make TortoiseBlame automatically scroll to the same line the cursor is located in the opened file in Visual Studio.
Now to add those new commands to the file tab context menu, go to TOOLS->Customize..., select the Commands tab, click the radio button Context menu and then select Other Context Menus | Easy MDI Document Window.
Now you have to select the commands. Problem is that the custom commands are not shown with their title but only as External Command X with X being the number of the external command.
In my case, the commands were number 9-11, you might have to do some trial-and-error here. Just add the commands you think are the ones you added and then check if the right ones show up in the context menu.
NOTE: In Visual Studio 2010 to add a command to the right-click menu of a document’s tab, first you’ll need to right-click on a Visual Studio document tab to work around a Visual Studio bug. (Otherwise the Easy MDI Document Window context menu doesn’t show up in the Customize dialog.) Source

Resources