Skip to main content
  1. Posts/

How to navigate to your recent edits in Visual Studio

·3 mins

I’m still working on my talk about ReSharper at this thursday’s NNUG meeting in Trondheim, and I’ve discovered a lot of cool functionality that improves my experience in Visual Studio. One thing I regularly use is “Navigate Backward”, to back track my steps and locate previous lines of code I have modified. The problem with this command is that it also navigates to places you only have positioned the cursor, and not only to where you actually made the changes. In addition, if you close a code window it’s history is lost, and the edits aren’t persisted between instances of Visual Studio. Here is an example of how this looks, after I made multiple modifications to multiple files that I later closed:

image
 

Tip: If you don’t see the “Navigate Backward” and “Navigate Forward” buttons on the standard toolbar, you probably doesn’t use the General Development environment settings. You can manually add the buttons by customizing the toolbar (they are located in the View category), but when I tried that I didn’t get the drop down functionality as shown in the screen shot above. What I did instead was to import the menu and toolbar settings from the General Development template by following these steps:

  • Select “Tools -> Import and Export Settings…”
  • Select “Import selected environment settings” and click “Next >”
  • Choose if you want to save your current settings or not and click “Next >”
  • Select “General Development Settings” and click “Next >”
  • Remove all check boxes
  • Check the node “All Settings -> General Settings -> Menu and Command Bar Customizations”
  • Click “Finish” to reset your toolbars and menus

ReSharper has two commands that help improve on these limitations. The first is a simple “Last Edit Location” command which move the cursor to the previous line you edited. The second command is “Recent Edits”, which pops up a list of the last 30 locations you have modified:

image

Here you see every location I’ve edited in the solution, and even closed files are listed. This example is from my demo, and I’ve documented the various shortcut keys, and with ReSharper’s Visual Studio keyboard binding the shortcut for Recent Edits is Ctrl+Shift+,.

Note: The edits aren’t cleared when you select “Clear Caches” from ReSharper’s option dialog, but you can manually delete these items by removing them from the RecentEdits element in ReSharper’s user configuration file. The file is named .4.1.resharper.user and resides in the solution folder.

Disclosure: JetBrains will provide me with a ReSharper and dotTrace license after my talk at NNUG, but they are in no way influencing what I think of the products or what I share with you on this blog or in my presentation.