NDepend

Improve your .NET code quality with NDepend

10 Visual Studio Files and Layout Productivity Tips

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 is an excellent way to quickly learn Visual Studio productivity tips. See others related posts based also on short GIFs here:

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.

Visual Studio Apply Window Layout
Visual Studio Apply Window 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.

Visual Studio Files Tabs Layout
Visual Studio Files Tabs Layout

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.

Visual Studio Tabs Sorting: Alphabetic order vs. Recently Opened First/Last
Visual Studio Tabs Sorting: Alphabetic order vs. Recently Opened First/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.

Visual Studio: Horizontal Split of Code Editor
Visual Studio: Horizontal Split of Code Editor

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:

  1. First Window > New Window menu
  2. 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.

Visual Studio: Vertical Split of Code Editor
Visual Studio: Vertical Split of Code Editor

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.

Visual Studio Document Group
Visual Studio Document Group

Document groups is especially useful with ultra-wide monitor:

Visual Studio Vertical Document Group on Ultra-Wide Monitor
Visual Studio Vertical Document Group on 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:

Visual studio Document Group with Left and Right Tabs
Visual studio Document Group with Left and Right Tabs

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.

Visual Studio: Open File Recently Closed
Visual Studio: Open File 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.

Visual Studio :Dock and Undock a Window
Visual Studio :Dock and Undock a Window

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

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.

Visual Studio: Code Diff
Visual Studio: Code Diff

The diff view can also be opened from within Visual Studio Command Window with this command:

Visual Studio: Command Window Code Diff
Visual Studio: Command Window Code Diff

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.

Source Diff with NDepend in Visual Studio
Source Diff with NDepend in Visual Studio

Conclusion

I hope that after spending a few minutes reading this post you’ll improve your productivity as a Visual Studio user 🙂

My dad being an early programmer in the 70's, I have been fortunate to switch from playing with Lego, to program my own micro-games, when I was still a kid. Since then I never stop programming.

I graduated in Mathematics and Software engineering. After a decade of C++ programming and consultancy, I got interested in the brand new .NET platform in 2002. I had the chance to write the best-seller book (in French) on .NET and C#, published by O'Reilly (> 15.000 copies) and also did manage some academic and professional courses on the platform and C#.

Over the years, I gained a passion for understanding structure and evolution of large complex real-world applications, and for talking with talented developers behind it. As a consequence, I got interested in static code analysis and started the project NDepend.

Today, with more than 8.000 client companies, including many of the Fortune 500 ones, NDepend offers deeper insight and understanding about their code bases to a wide range of professional users around the world.

I live with my wife and our twin babies Léna and Paul, in the beautiful island of Mauritius in the Indian Ocean.

Leave a Reply

Your email address will not be published. Required fields are marked *