Visual Studio - Hints, tricks and tips

etienne_marais

Honorary Master
Joined
Mar 16, 2008
Messages
15,093
Visual Studio is highly configurable with a vast array of features. There is plenty of documentation, blogs etc. available but it can be overwhelming and unclear what to focus on for effective development.

Tip 1 (Editor - Navigation) - Navigate to previous/next marker drop.

Shortcut: control + minus/dash for previous, control + shift + minus/dash for next.
[Shortcut can be edited under Tools->Options->Environment->Keyboard->View.NavigateBackward]

A marker drop is basically an automatic mechanism to remember where in the editor your cursor was previously. It works across multiple files. It will re-open a closed file. Especially useful when you did not foresee the need to navigate back to a location (such as when a bookmark was not created).

According to this blog a marker is automatically dropped when:

The editor remembers locations when you move in a single command more than several lines away from where you are currently working, or if you edit in a particular location that is not adjacent to the last place you edited.

The goal is to remember interesting locations so that you can recall where you have been working without remembering so many locations the feature is not useful (such as every character typed, or every line entering several new lines of code one right after the other).

A go-back marker is dropped under the following conditions:

An incremental search (including reverse) leaves a go-back marker at the beginning of the search and another one at the end.

A Go To Line action, like CTRL + G, or a mouse-click that moves the cursor 11 lines or more from the current position drops a go-back marker at the new location.

A destructive action (like hitting Backspace) after having moved the cursor to a new location drops a go-back marker.

Doing a search, like Ctrl+F, drops a go-back marker at the found location.

Opening a file drops a go-back marker wherever the cursor was on the old file and drops another on the opened file.

Menu: View -> Navigate Backward; View -> Navigate Forward
[Menu item can be added/deleted under Tools->Commands->Menu Bar (select preferred menu from dropdown)->View->Add Command->Navigate Backward]

Right-click context menu action: None
[Context Menu item can be added/deleted under Tools->Commands->Context Menu (select "Editor Context Menus | Code Window" from dropdown)->View->Add Command->Navigate Backward].
 
Last edited:

Solarion

Honorary Master
Joined
Nov 14, 2012
Messages
21,885
I wouldn't mind knowing how to get the code margin lines in VS 2015. I know they are there by default in 2017 but I am sure I have seen someone with them previously.
 

etienne_marais

Honorary Master
Joined
Mar 16, 2008
Messages
15,093
I wouldn't mind knowing how to get the code margin lines in VS 2015. I know they are there by default in 2017 but I am sure I have seen someone with them previously.

You're talking about the enhanced scrollbar with the code preview ?

Tools->Options->Text Editors->All Languages->Scroll Bars then use map mode & show preview tooltip
 

Curious_Al

Well-Known Member
Joined
Jun 9, 2016
Messages
218
Download the extension productivity power tools. There's a lot of useful shortcuts but the only one I use is the automatic removal of unused namespaces upon clicking save.
 
Top