navigate to calling code Visual Studio - visual-studio

I want to know that we can use F12 to jump to the function that is called from this code , if i have to return to the code again how I can do this.

I believe that the command you're looking for is "Navigate Backward", available from the View menu (or CTRL+-). It has a companion command, once invoked, called "Navigate Forward", also on View menu (CTRL+SHIFT+-).
You can use these to move back and forth through a chain of Calling/Callee functions. Obviously, if you're not using the usual Visual Studio shortcut mappings, then the key combinations above may be different (or you may have to assign keys yourself).

Related

Visual Studio : How can I remap the Ctrl+E key?

I am using Visual Studio 2013, and I would like Ctrl+E to map to Edit.LineEnd. Basically, the same thing that happens when you hit end.
I can remap it under options/environment/keyboard, but the problem is visual studio still treats Ctrl+E as a chord. Instead of going to the end of the line when I hit Ctrl+E I see a message below :
(Ctrl+E) was pressed. Waiting for second key of chord.
This does not happen when I remap Ctrl+A, Ctrl+N, Ctrl+P, Ctrl+F, or Ctrl+B.
This looks like a side effect of how Visual Studio layers command routing and key bindings...
If you look at the default bindings (my settings were based on the C# profile), you can see there are a ton of other bindings that start with Ctrl+E:
Important observations:
Each command has its context specified in parenthesis (Global, Text Editor, Workflow Designer)
There is already a multi-key (chord?) binding in the Text Editor
The Workflow Designer bindings don't matter/conflict because they're in a completely separate context
If you set your binding in the Global scope, it falls last on the priority (i.e. any specific context overrides a more generic one). Since you're in the text editor, it's trying to match the chord that exists in that context.
If you were to bind your new shortcut in the Text Editor (that's the dropdown labeled Use new shortcut in:, which defaults to Global), it would actually remove the keybinding for Edit.ToggleWordWrap. That's because you can't have a keybinding overlap with a chord, so VS assumes you really want the one you're trying to add and nukes the conflicts.
Alternatively, if you want to keep both, you could remap Edit.ToggleWordWrap to a different binding first.

Is there a keyboard shortcut to move the cursor between methods in Visual Studio 2010?

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

Find out what class a method belongs to (in Visual Studio or Resharper)

If I'm looking at a method definition in Visual Studio (with Resharper) is there an easy way to find out what class it belongs to? (As of now, I've resorted to a text search in the "up" direction for the string "class".)
The Resharper command Go to containing declaration (ctrl + [) should do the trick
Edit:
Or if you have the navigation bar at the top of the code window enabled, that should display the type name. But I have that turned off, since I use keyboard navigation and the bar itself slows down Visual Studio.
You have files with more than one class in? That makes ponies sad...
Anyway, to actually answer, can't you just look at the navigation bar?
The best (direct) way specific to your question is PHeiberg's answer.
But if you ask this question I guess you don't know the File Structure window that can be enabled by ReSharper->Windows->File Structure or by shortcut Ctrl+Alt+F.
With that window you see always where you are in your file.
Aside from using ReSharper's File Structure and/or Go to Containing Declaration - options mentioned previously - there's also a tiny feature in ReSharper called Quick Documentation that in my view is better suited for this kind of task since it shows you method info in-place, without forcing you to navigate anywhere from the method you're on. Ctrl+Q, Esc, and you're done. It works on all kinds of symbols (not limited to methods), both on declarations and on usages.
For VS, right click on the function and select 'Go To Declaration'. (Ctrl + F12)

How to assign keyboard shortcut to open a solution folder from visual studio?

I'm trying to assign a keyboard shortcut to open a solution folder (the one you get when right click on solution name) from Visual Studio. Looking in keyboard options in Options didn't help (searched for "folder", for "open" etc.)
Have I missed something ?
This is it:
ProjectandSolutionContextMenus.Project.OpenFolderInWindowsExplorer
It works, but I'm sure how you get the solution selected first?
Please let us know if you can solve it elegantly, I'm interested because I don't currently use AnhkSVN or VisualSVN, I prefer TortoiseSVN, but it would be nice to open the solution folder since that's normally the root.
You can assign a keyboard shortcut to a macro using this example
Assigning a Keyboard Shortcut to Macro in VS
Last time I forgot to mention one
important thing - how to assign a
keyboard shortcut to your macro. Often
you don’t need any button for your
macro, the shortcut is enough. Or you
can have both. As I already wrote,
macro is similar to any named command.
So to assign a shortcut to it:
Go to menu Tools - Options… and select Environment - Keyboard.
alt text http://www.helixoft.com/blog/wp-content/uploaded/keyboard_options.png
Find your macro in the list of commands. All macro names start with
“Macro.”. To filter out other commands
enter your macro name in the Show
commands containing field. If your
macro is named test as in our example
then type test. Select your macro.
Go to Press shortcut key(s) field and press your shortcut. If the
shortcut is already in use, you will
see it. Press Assign button.
Remember that you cannot change or
assign the shortcut if you are using
predefined keyboard mapping scheme.
You will be warned in this case. You
must create a copy of current scheme
and use that copy. Press Save As…
button under Keyboard mapping
scheme and give it some name. Then
select this new scheme.
There probably isn't a keyboard shortcut defined for that, but Visual Studio has excellent macro support, and you can create your own macro to do that.
There's a Macro Recorder feature that you can use. This MSDN article explains how to use the Macro Recorder.

Is there a hotkey in Visual Studio to open the member drop down list?

In Visual Studio there is a drop down list in the top right hand corner that you can use to navigate to the various members in the class. Does anyone know if there is a hot key to open this ddl?
I think you're looking for Ctrl + F2, which moves the cursor to the navigation bar at the top of a code view. From there, you can press Tab to move the cursor over to the member list.
For this (and pretty much every other Visual Studio hotkey/shortcut key combination), see here.
Visual Studio 2017+: They now support Resharper-like shortcuts. They work pretty well, too.
Ctrl+T - 'Go to All' (class/member/file), type m MyProp for members only
Alt+\ - 'Go to Member in current file'
Using VS 2008, I still don't know how to get directly to the Members dropdown which is what I want. But, the key bindings will be different for everyone. The command you want to search for under Options > Keyboard > Show commands containing: is Window.MoveToNavigationBar.
Assuming you are using the default keybindings packaged with Visual Studio, CTRL+F2 will focus the top-right drop-down list, and you can then navigate members by pressing TAB and using the arrow keys.
In my install of VS 2013, this is called Window.MoveToNaviationBar and is bound to Ctrl+F8. This is visual C++ settings.
Use Ctrl + F2 to get up there, then a click on Tab will get you to the member list instead of the object list.

Resources