It returns your caret(aka cursor) to the place where you stopped writing code(very useful for fast code browsing)
Ctrl + - will move to the previously browsed line of code (Ctrl + Shift + - will move forward). You can download PDF versions of all the default keybindings in Visual Studio 2010 from this page.
ReSharper has Ctrl+Shift-Backspace to return to previous editing position. Or Ctrl+Shift+, (Comma) to browse some recent edition places.
In addition to what is mentioned in the other answers, you can use the undo/redo trick. As long as you want to navigate to the last edit position in the current file, a quick undo/redo will take you there.
You are looking for View.NavigateBackward. The actual keystroke depends on your personal settings, but it's probably Ctrl + -. If not, go to Tools/Customize/Commands/Keyboard to find out what it is for your setup.
There are ctrl+- and ctrl+shift+- That navigate backward and forward.
Related
In visual studio 2022, when I ctr + click a method, I want to jump to the definition in new tab even if the definition is in the same file.
I can't track where I left currently since I enter several different methods while I read the code.
It's not yet possible. An extension plug-in (if it exists or one developed by you) might do the job. For now, the only thing that might help you out is using Bookmarks. Indeed, "travelling" back using Ctrl + - might be daunting, but it's the only way possible (which is why I recommend Bookmarks combined with navigation).
TLDR: Not yet possible. Maybe make an extension OR the closest you can get is if you use Bookmarks alongside navigation.
Is there any keyboard shortcut to move the cursor between methods in Visual Studio? Is there any plugins that can do the same job?
All the time when I program, I want to go at the end of the current method and if I could have a shortcut that can move the cursor at the beginning of the next method and then just have to type a couple of up arrow to be where I want would be fantastic.
Thank you.
Note: For VS <2015, the following works only for the VB.NET code editor. In VS 2015+, apparently the C# code editor is also supported.
While there are no default keyboard bindings to jump between methods, you can set them up yourself:
Go to Tools → Customize…, then Keyboard…, and do the following:
Search for the commands by typing Method in the input line at the top.
Locate the two commands Edit.NextMethod and Edit.PreviousMethod.
For each of these, select the command first, then move the input focus to the input field Press shortcut keys, enter an unassigned key combination, and press the Assign button.
(The screenshot above shows that I have previously assigned one of these commands to Ctrl+Shift+<.)
Hi another (cheaper) alternative might be the CTRL+M+M to collapse/expand the current method to it's definition, allowing you to quickly navigate to the next.
Also CTRL+M+O to collapse all members is useful, with CTRL+M+L to expand all again.
Visual Studio doesn't have such a function, but JetBrains' ReSharper does. At least is the only one that I know of to offer this functionality.
For ReSharper the shortcuts are Alt-Up and Alt-Down, for previous/next member.
Try CTRL + ALT + UP. This first takes you to the scope selector where you can select a class if applicable, then press TAB which takes you to the method selector where you can select a method from the selected scope.
Note I use In Visual Studio 2012, don't know if works in other versions.
Jason Malinowski is right on his comment. It even says the shortcut keys are Ctrl+Down Arrow and Ctrl+Up Arrow. I used to use this all the time in VB6, but when I tried it lately using recent versions of visual studio, it didn't work; it would just scroll the edit window up or down one line.
When I went into Tools -> Options, select "Environment" on the left, and then the subcategory of "Keyboard", then type "Edit.ScrollLineDown" it said Ctrl+Down Arrow. When I removed this shortcut (and the one for ScrollLineUp), the next/previous method shortcuts then worked! I'm personally very happy about this.
Obviously, if you can find the right command, you can customize your keyboard shortcuts any way you please here.
I know this is old, but looks like it was added since.
Try Alt+[ or Alt+]
In Visual Studio 2013 with the commercial Visual Assist expansion you can use ALT+M to open a list with all methods in the current file. Select one, hit ENTER and the cursor will jump to it.
do not forget about the excellent, free DPack extension, which will add Alt+m shortcut which will open a list of all methods in the current class. You can type a search string to filter, and what is also great is if you tab down and enter on a method, and then later do Alt+m again, if you tab into the window you will be on the last method you selected. DPack also has many more features, like bookmarks, but I do find that you have to setup the hotkeys, or more exactly, re-assign hotkeys from other functions to DPack: https://marketplace.visualstudio.com/items?itemName=SergeyM.DPack-16348
Its Ctrl + } - by placing the cursot to end of line - using studio 2015
Same will also bring the cursor back to bottom.
so place the cursor at end of function and press Ctrl + }
In Visual Studio 2015:
Alt + Up or Alt + Down
Is there a keyboard shortcut to quickly find and open a file in Visual Studio 2005/2008 like how they do it in TextMate?
In textmate Command + T in Textmate brings up something that you can type a few key which would display all relevant files and allow you to quickly select one, Command + T back and forth also allows you to quickly alternate between 2 files most recently used. This is extremely helpful.
I am aware that there is a Ctrl + Alt + ↓ which shows a list of all open documents which is almost there but not quite.
You can hit Ctrl+D to go to the search box, then type >of filename (with autocomplete).
You can also do this and other commands in the command window or the immediate window.
Or, if you don't mind buying, ReSharper has Go to File which I highly recommend. It's Ctrl+Shift+N and it brings up a nice search dialog that supports wildcards and other shortcuts.
Sonic File Finder is a free VS plugin which is basically the same thing, and quite well-loved by most people who install it.
http://www.jens-schaller.de/sonictools/sonicfilefinder/index.htm
I think the best solution is the following
CTRL + , (comma) then type your file/class/method name
I've made an extension that works exactly like Textmate's "go to file" feature: https://github.com/maxt3r/VS-CmdT
If you go to the search box in visual studio and type ">open " and then start typing, autocomplete will come up for all the files in your solution. This is in 2008, not so sure about 2005.
Out of the box in Visual Studio, Ctrl + Tab will toggle between the two most recent files.
Ctrl+Shift+T in Resharper works just like you describe. It provides a text box in which you type the filename and it generates a live list from which you can pick from. Nice features include wildcarding (e.g. Customer*xaml) and matching on camel case filenames (e.g. SVD will match SingleValueDecomposition.cs). At my work, if people use one feature of Resharper, it will be Ctrl+Shift+T.
If you code in C++ rather than C#, then Visual Assist provides some functionality. And in my opinion, works better than Resharper.
Sara Ford has a blog post about this: Did you know... How to open a file in the solution without using either a tool window or a dialog?
All the previous responses are accurate and are mentioned in her post and the comments. In addition, another approach is to launch the command window using CTRL+ALT+A then typing in "of filename" or "open filename" in the same way mentioned for the search field.
#Adam Neal mentioned ReSharper. Another popular tool is CodeRush/Refactor! Pro and it also has a file navigation window that can be launched (and searched) via the CTRL+ALT+F shortcut.
Ok, I am not sure what the naming for this is actually called, but I would like to know if the following is possible in Visual Studio.
When I set my cursor on or highlight a variable, or method name, or string... etc, I would like the IDE to highlight all uses of it. So if I highlight variable x, then it highlights all other uses of variable x.
This is done in eclipe and Notepad++, and I have become very fond of that feature, but when I move to VS, I cannot seem to get that functionality.
I know I can use the right click and find definition, also I can use resharper to find all uses, but that is not as easy and intuitive. I am currently using VS2008, but would like it in both 2008 and 2005.
Also, if this is a feature of resharper that I just don't see, that is good too.
Thanks
With Reshaper you can press Shift+Alt+F11 when your cursor is inside a variable to highlight all usages of that variable in that file. (Then ESC to remove the highlighting)
This is not a feature of Visual Studio 2008 or previous versions. It will be a feature of Visual Studio 2010 though.
http://blogs.msdn.com/somasegar/archive/2008/12/19/code-focused-development-in-vs-2010.aspx
With ReSharper, if you're using the IDEA keybindings, use Ctrl+Shift+F7. If you're using the VS keybindings, use Shift+Alt+F11 (like Martin Harris said).
You can find the full map of keybindings here: ReSharper Feature Map
A VS plugin that I use, WholeTomato's Visual Assist X, does this. If the thing being highlighted is a variable, it will even show assignments and reads in different colors.
DevExpress Refactor or Code Rush (I have both, so I'm not sure which) will do this.
Place the cursor on a variable and hit tab; all uses of the variable that are in scope will be highlighted.
In Visual Studio, have the variable selected(you can also select methods etc.), then in the top menu go to Resharper -> Find -> Highlight Usages in File or press Shift + Alt + F11 on the keyboard.
Then if you want you can navigate down trough the usages with Ctrl + Alt + PgDn and upwards with Ctrl + Alt + PgUp.
I use Delphi for many years, and although I have now moved on to Visual Studio I still fondly remember numbered bookmarks (CTRL+K+1 to set bookmark 1, CTRL+Q+1 to goto bookmark 1).
Is there a Visual Studio equivalent? I'm find the dumb bookmarks in VS a chore after Delphi. I want to bookmark then return to a specific place in the file.
DPack can give you numbered bookmarks in VisualStudio.
Ctrl K + Ctrl K - Add/Remove Bookmark on Line
Ctrl K + Ctrl N - Go to Next Bookmark
Ctrl K + Ctrl P - Go to Previous Bookmark
There are other options as well. Look under Edit->Bookmarks menu,
More a comment on your original question than an actual answer but Delphi has had much easier to remember (and type) keyboard shortcuts than what you quote available for quite some time now:
Set bookmark 1: Ctrl-Shift-1
Go to bookmark 1: Ctrl-1
If you ever go back to Delphi, this should make your life so much easier! ;)
Just to amplify Lars Truijens answer. DPack is a GExperts like plugin for visual studio. I found it great help when moving from the Delphi IDE to Visual Studio.
I find this one also very useful:
CtrlK + CtrlL - Clear alll bookmarks
There is a Bookmark Window. Go to menu View/Bookmark Window (Ctrl+K, Ctrl+W).
In there you can see all your bookmarks and rename them. That is a lot better than just seeing the numbers.
For some reason they don't allow to order that list by clicking in a column header, but you can drag the bookmarks and accommodate them in the order you want.
VSBookmarks gives something like the fantastic Delphi bookmarks feature. Tested and works in Visual Studio 2019.
Extensions > Search "VSBookmarks" (v1.7 at time of writing)
Install and restart Visual Studio
Use Ctrl + Shift + N to set a bookmark
Use Ctrl + N to move to a previous bookmark
There will likely be conflicts with existing keyboard shortcuts. To view and edit these:
Tools > Options > Environment > Keyboard
In "Press shortcut keys" type Ctrl + Shift + 1
See which command(s) are currently assigned to the shortcut
Find the command in the list and remove the shortcut
Repeat for Ctrl + Shift + 1 through Ctrl + 9
VSBookmarks applies only within the current file (which is the Delphi behaviour), but is not configurable with just a single colour for the bookmark.
Delphi is an awesome language and editor. Thanks to Sergey Vinyar and Alessandro Fragnani (for the Numbered Bookmarks extension in Visual Studio Code) for keeping the flame alive.
I use:
CTRL-F2 toggle bookmark
F2 next bookmark
SHIFT-F2 previous bookmark
CTRL-SHIFT-F2 clear all bookmarks
BTW, after using Visual Studio for years I just found about a couple of months ago that you can press ALT and drag mouse to mark a column or a square.