Among the multiple daily development tasks (planning, testing, refactoring, bug fix…) code edition is arguably the most satisfying one. Code edition can be even more satisfying and productive by mastering the following Visual Studio productivity tips. In my opinion these tricks are not optionals: they should be part of all Visual Studio developer skills.
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) Move one or several lines up and down
The line that contains the editing caret can be moved up and down with Alt+Up and Alt+Down.
The same way several lines selected can be moved up and down.
2) Rectangular Selection
Rectangular selection is very useful to quickly edit a code portion. This can be achieved with Alt+Shift+Arrows shortcuts.
3) Multi-Lines Edition
Once mastering rectangular selection, it can be used to edit multiple lines at once:
4) Multi-Carets Edition
Often we need to repeat the same edition at multiple locations. To do so multiple carets can be defined with Ctrl+Alt+Mouse Click:
5) Multi-Carets Edition on Same Matches
Multiple carets can be set to next locations of the selected word. To do so first select the word and then use Ctrl+Shift+; .
Multiple carets can be set to all locations of the selected word with Ctrl+Shift+$ .
6) Expand / Contract Selection
You can expand the selection with Shift+Alt+= and contract it with Shift+Alt+.
7) Make Selection Uppercase / lowercase
You can Uppercase the selection with Ctrl+Shift+U and lowercase it with Ctrl+U
8) Outlining
The most important keyboard shortcut when it comes to outlining is Ctrl+M Ctrl+M. This shortcut expands / collapses the code portion that contains the caret.
Not all developers enjoy outlining and if you are one of those, you can discard it with Ctrl+M Ctrl+P.
9) Vertical Scrollbar Map Mode
The map mode is one of the most useful Visual Studio code editor facility. It does really help finding your way in source file.
It can be set from Visual Studio > Tools > Options > Text Editor > All Languages > Scroll Bars > Behavior.
The width of the map can be: Narrow Medium Wide
10) Bookmarks
When developing we often have to come back and forth through multiple locations in several source files. Fortunately you can concretely define this locations-set with bookmarks. Here are bookmarks shortcuts:
- Ctrl+K, Ctrl+K to toggle a bookmark at caret position
- Ctrl+K Ctrl+N go to Next bookmark
- Ctrl+K Ctrl+P go to Previous bookmark
- Ctrl+K Ctrl+L clear all bookmarks
Note that Visual Studio remembers bookmarks when closing it and restarting it.
11) Bonus: Visual Studio 2019 Clipboard Ring Preview
Ctrl+C copy some data to the clipboard. Actually Visual Studio maintains a clipboard ring to store several data.
With Visual Studio 2019 Ctrl+Shift+V shows a preview of the various data in the clipboard ring. This is quite useful to navigate through the copy history.
Conclusion: Visual Studio > Edit > Advanced
The Visual Studio menu Edit > Advanced is both a good start and a good reminder for code editor keyboard shortcuts.
There are more sub-menu including Bookmarks, Outlining, Intellisense and Multiple Carets.
I like the ninja-coder analogy because these tips must be repeated again and again as kata to be mastered in your daily coding routine.
Kata is a Japanese word meaning literally “form” referring to a detailed choreographed pattern of martial arts movements made to be practised alone, and also within groups and in unison when training. It is practised in Japanese martial arts as a way to memorize and perfect the movements being executed
Why not take 8 minutes now with this background theme and practice?
Be curious: there are many more Visual Studio facilities that will help becoming a ninja coder, first one being code snippets.
Almost all of these do not work for me with ReSharper and VS2017.
Hi Patrick,
Your tricks are so cool and the topic “12 Visual Studio Debugging Productivity Tips” is very good.
Best regards and stay safe,
[]s Jose
PS.: Could be a version of nDepend to VS Community??? Think about…