Visual Studio 2017 is currently the most robust IDE to use for programming with C# in Unity®, and is the most commonly used IDE in general game development. That said, it’s good to know how to set up the most efficient workflow for yourself when using it, as Visual Studio comes with some unintuitive functionality out-of-the-box.
In this article, I’ll show you the most important features to use in Visual Studio 2017, and I’ll show you which keybindings I use to become the most efficient Unity® developer I can be.
Before I tell you all of my settings, you’ll have to know how to set keybindings. If you already know how, you can of course skip this section of the article.
To set keybindings in Visual Studio, you’ll have to open the Tools menu, then click Options, then collapse the Environment drop-down menu, and select Keyboard. The interface that you pulled up will now allow you to search commands by name and assign a key to them.
The most hilariously missing thing in Visual Studio is the inability to toggle comments in and out. If you’re unfamiliar with this feature, you’ll want to use it mostly to test certain features by enabling or disabling certain lines of code. It’s much more efficient than deleting lines as you can just leave the lines where they are, set them as a comment, and then uncomment them when you want them to run again.
To enable comment toggling, you actually have to install a plugin, which is very simple. Personally, I use the ToggleComment plugin which you can find here.
A common feature among IDEs is the ability to quickly position your typing cursor at the header of a function. Visual Studio includes a next method and a previous method command to which you can bind a key. Here are their respective commands, and the keys I’ve bound to them:
Command Name: Edit.NextMethod
My Keybinding: Ctrl+Alt+Down Arrow
Command Name: Edit.PreviousMethod
My Keybinding: Ctrl+Alt+Up Arrow
This next command is used for jumping the typing cursor to the declaration of a referenced member. By default, Visual Studio has this command set to F12, which for me is annoying to reach over and press. I recommend changing it to something you can press with your keyboard hand as you will likely want to look at the definition of a function often when debugging. Here is my binding:
Command Name: Edit.GoToDeclaration
My Keybinding: Ctrl+Shift+D
You can also view the references of a member just like you can its declarations. Once you send this command, it will display a list of every line in every file where the selected member is referenced or used. Here is my binding:
Command Name: View.ShowReferences
My Keybinding: Ctrl+Shift+R
This command isn’t really as important as all the others, but it can come in handy once in a while. The select word command will select the word your typing cursor is currently in or adjacent to. I’ve set mine as follows:
Command Name: Edit.SelectCurrentWord
My Keybinding: Ctrl+D
This part is straightforward. When navigating through tabs, the “next” tab is to the right of the currently selected tab, and the opposite for the “previous” tab. I’ve also rebound the close tab key. Here are my configurations:
Command Name: Window.NextTab
My Keybinding: Ctrl+Alt+Right Arrow
Command Name: Window.PreviousTab
My Keybinding: Ctrl+Alt+Left Arrow
Command Name: Window.CloseTab
My Keybinding: Ctrl+W
All right, those were the commands I find most important to keep accessible as I use them the most when working on games. Each time you employ things like this that speed up your workflow, you’ll become a bit more efficient since you’re able to focus more on your code and game design. Thanks for reading, and I’ll catch you in the next post!