is there a way to edit all reference highlights in visual studio? - visual-studio

Usually in vs2015 and vs2017 (at least) when you select a word, automatically all the references of the word get selected. I would like to know if there is a way to edit all the occurrences using a keyboard shortcut (placing multiple cursors without the searching dialog), as an example, let's say that in the image below i would like to replace the "Some" with "Very".

Try right-clicking your reference, then choosing "Rename..."

There is at least one plug-in, Multi Edit Mode, but you can just modify the function name and use the light bulb/quick actions (Ctrl .) to rename/refactor all references to the function.

Related

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)

Switch to tab by typing a substring of its name in Visual Studio 2005

Is there a way to navigate between tabs in VS similar to the emacs iswtichb-mode or Firefox ubiquity switch tab mode (https://wiki.mozilla.org/Labs/Ubiquity/Ubiquity_0.1_Author_Tutorial#Switching_Tabs) ?
In these apps, you just type a substring of the title of the tab (or buffer for emacs) to switch to this tab. For instance, to switch to a tab named "App_Code/Data/MyProgram.cs", you just invoke the tab switching command and then type "Progr" for instance to list all the tab whose name matches this string, including "MyProgram.cs".
It's much easier to switch between tabs this way when you have a lot of documents open and when you now where to go (which is the case in most situation)
Thank you !
Visual Assist has a function "Open File in Solution" (shortcut Shift-Alt-O), where you can type the filename and list of matching files from the solution is shown. Once you are happy with the selection, you can confirm it by pressing enter, or you can click the file you like with mouse.
As added bonus, this way you can also switch into files which you do not have open in a tab yet.
No this is not a supported operation in Visual Studio. It can be done by adding a Macro or via a plug-in though.
ReSharper will do something similar to this for you. It's not free, but it has many really nice features.
Invoke with Ctrl+T, then start typing the name of a file. It will provide you with a list of matches while you type. It's not limited to open tabs; it searches all files in the solution.
The search is intelligent. For example, if you have ThisIsMyClass.cs, typing 'TIMC' or 'ThisIMCla' will still match based on the idea that capital letters begin new words in file names.

ViM-like search highlight in Visual Studio possible?

ViM has this option hlsearch where a searched string is displayed in highlight mode at all places in the file it is found. Is there a way to do the same in Visual Studio?
That is, if I search for "foobar", then all the foobar in the file are shown highlighted and this display remains until my next search. I find this very useful to see the places in a function where a certain variable is used (without having to manually search for the next appearance of that string).
I am aware of the Visual Studio Task List which can be used to look up strings like TODO. I hope the reader realizes that this is not a good fit for my problem which is more general text search and highlight.
If you like vim and are using Visual Studio you may want to check out Viemu.
The hlsearch Feature is of course included.
Example Picture:
Viemu hlsearch http://dklein.taunus.de/viemuhlsearch.png
With best regards.
Visual Assist X does this, along with something akin to light-symbol-mode. Among other things, of course.
Visual Studio 2010 now supports Reference Highlighting. Click on or move the cursor to any symbol such as names of variables, classes, methods, properties, etc. and it will highlight all other references in the file. It also allows you to navigate between the references using:
ctrl+shift+down arrow or ctrl+shift+up arrow
I use the RockScroll add-in. It has multiple features, one of them is that if you double click on a word it will be highlighted everywhere in the file. This is very similar to what you describe. It is free (as in beer).
If you happen to really like Vim, you might want to look into ViEmu for Visual Studio . I'm just a really happy user of it :)

Can Ctrl+Backspace be made to work in VS2008's Solution Explorer?

I'm working in an ASP.NET MVC Beta 1 project, and I've noticed that if I want to rename a file in the Solution Explorer pane, Ctrl+Backspace does not do what it should (delete the closest "word"), and I get a silly box character and annoyed.
I'm doing this rather a lot as I'm using jTemplates, so rather than train myself out of using this very useful key combination, is there a way to make this function as expected in VS2008?
Probably not. File a bug on connect.microsoft.com, and hope that they fix it in VS 2010.
I'm not sure if this completely works, but if you go to Tools -> Options: Environemt -> Keyboard, you can set up short cuts.
Type "Rename" in the Show commands containing textbox.
Search for "File.Rename"
Put your cursor in the "Press shortcut keys" textbox and press Ctrl+Backspace.
Press Assign and it should take over the shortcut combination.
Hope that works for you.

Resources