Nowadays most developers are working remotely. Hence the monitor(s) configuration might have changed, and might change frequently. In this context, it does matter to optimize the Visual Studio layout and documents access. Here are some tips.
Short GIF animation is an excellent way to quickly learn Visual Studio productivity tips. See others related posts based also on short GIFs here:
- 10 Visual Studio Solution Explorer Productivity Tips
- 10 Visual Studio Ninja Code Editor Productivity Tips
- 12 Visual Studio Debugging Productivity Tips
- Top 10 Visual Studio Refactoring Tips
- 10 Visual Studio Navigation Productivity Tips
- 10 Visual Studio Files and Layout Productivity Tips
- 14 Visual Studio Web Development Productivity Tips
1) Save and Apply Windows Layout
The menu Window proposes 4 sub-menus to Save, Apply, Manage and Reset the Visual Studio windows layout. You can use this feature both to switch back and forth between several monitors configurations and also to switch between various activities (code writing vs. testing vs. code review …). The hotkey Ctrl+Alt+Number N instantly switches to the Nth layout.
2) Vertical Documents Tabs
You can place the documents tabs on the left or on the right. This is especially useful if you work with an ultra-wide monitor and have much more width space than height space.
3) Sorting Files Tabs
When tabs are on the left or on the right, files are sorted per project. Per default, under each project tabs are sorted alphabetically. They can also be sorted by Sorted by Recently Opened First or Sorted by Recently Opened Last.
4) Code Editor Horizontal Split
You can split horizontally the edition of a file through Window > Split. This is especially useful when visualizing or editing two locations in a large file.
5) Code Editor Vertical Split
Vertical split is not as straightforward as horizontal split explained in the previous tip. Vertical split requires a two step process:
- First Window > New Window menu
- Second right-click the tab, New Vertical Document Group
I wish there was a button to switch back and forth from horizontal to vertical split.
6) Document Group
The previous tip was based on document group. Document group is primarily used to create horizontal or vertical groups of files edited.
Document groups is especially useful with ultra-wide monitor:
7) Document Group and Vertical Documents Tabs
Document group works well when tabs are shown on left or right. Projects and files are then grouped by Tab Group sections:
8) Open a File Recently Closed
The Go to All dialog can be triggered with Ctrl+t. Then just type r and the list shows recent files, including the files that have been recently closed.
9) Dock and Un-Dock a Window
To dock and un-dock a window just hold the key Ctrl and double click the window title bar. This is much faster than dragging the window with the mouse.
10) Compare Files with Visual Studio
Visual Studio proposes an excellent file diff tool. However this tool is not easily accessible so most of users ignore it. You can diff through command line with the devenv.exe /diff command
1 |
devenv.exe /diff C:\Old\Program.cs C:\New\Program.cs |
If a Visual Studio instance exists it’ll be used to host the diff view, else a new Visual Studio instance gets started to host the diff view.
The diff view can also be opened from within Visual Studio Command Window with this command:
1 |
Tools.DiffFiles C:\Old\Program.cs C:\New\Program.cs |
The Visual Studio diff feature is used by NDepend when comparing against a baseline inside Visual Studio. NDepend creates a snapshot of your code base by zipping all source files at analysis time. The tool then proposes the menu Diff since Baseline when right clicking an item in the Solution Explorer or a code element in the Code Editor.
Conclusion
I hope that after spending a few minutes reading this post you’ll improve your productivity as a Visual Studio user 🙂