How to fix Visual Studio 2012 replace all dialog? - visual-studio

When I do a ctrl+shift+h to open the Find and Replace All dialog the cursor is in the Replace With textbox instead of in the Find What textbox like it should be ala Visual Studio 2008.
This means I have to shift+tab to go to Find What - it's completely infuriating and makes no sense. I'd prefer that it's focused in Find What then I should tab into Replace With but I can't find setting for this.

The reason for that is so you can select the text you want to find in the IDE and then hit ctrl + shift + h. It will prepopulate the Find field with the text you selected and will take you directly to "Replace with" field so you can specify what you want to replace it with. I don't think there is any way you can change that behavior.

You can use ctrl+f and extend the dialog to use as replace. If pressed ctrl+f Focus is always in the correct(search) field.

Related

Map keybind to specific snippet - SQL Management Studio / Visual Studio

I review a lot of code and I want to put brackets around certain text elements that lacks them. So far I've been been doing the following:
1) Highlighting the text element I want to put brackets around (only one highlight at a time)
2) Hit ctrl-k + ctrl-s to invoke the "Surrond With..." shortcut (see Edit->IntelliSense->Surround With...
3) Find my "insert bracket" code snippet and then hitting enter
I want to keybind a specific snippet to do this in one go (just like when you are commenting out a block using the keybind ctrl-k + ctrl-c. Is this possible?
This question is smiliar to Assign code snippet to keyboard shortcut in Visual Studio but its not marked as answered. Can anyone help confirm that its not possible or whether another work-around is possible.

Visual studio Reformat Code/Document

I can't find the Reformat button, I know I can use ctrl+k+d, but I wish to have also the toolbar with the button. can someone help me ?
You can use Edit > Advanced > Format Document and you can also move this as a button to any toolbar. Go to Tools > Customize > Commands, select Toolbar and push Add Command button. Then select Edit category and find Document Format.
Apparently VS2010 (maybe others) hide certain commands depending on the style you choose. I chose Web Dev (code) as my choice and the Document Format is not present to be added to a toolbar. But, if I change to C# Code (tools>Import/Export) then the Document Format command is right there in the Edit menu where others here have said it is.
I had to import the C# Dev layout, but unchecked colors and code formatting options (so it won't overwrite those). What section you must import to get the format document button, I don't know, I didn't experiment that deep.
Seems stupid MS chose to force us down specific paths for layout with no convenient way to get out of it.
If you can't find it in the Edit menu: you can also find it if you press CTRL + P and then type >format. The shortcut is SHIFT + ALT + F

How can I count a specific variable in the code in Visual Studio?

HI
I understand that we can search specific word/Variable in VS2010 editor. For example, If I used a variable called (MyTest) and I want to count how many times I used this variable/word in the code of say (10000) lines.
If possible, how can we do it in the current form or count the word in all form the project?
Thanks!
Assuming you wont to search for "MyVariable" press Ctrl+H and the Find/Replace Dialog should open. Enter "MyVariable" into the "Find what" field and again into the "Replace with" field. Set the Scope to "Current Document" and press the "Replace all" button. A message will popup telling "xxx occurrence(s) replaced.", where xxx is the number you are looking for.
Press the "undo"-Button once, if you want to revert the document-state to unchanged.
Can you not highlight the variable and press Shift+F12? This will tell you all of the matches found.
If you want to find the text "MyTest", here is a hacky way to do it.
Use the find dialog (CTRL F) to search for the text. You can modify the scope. eg Document, project etc
Click Bookmark all
Then open the Bookmarks window (View-Bookmark window) to see a list of all the bookmarks. It doesn't show the total number but you could easily count them manually here.
Ctrl + Shift + F to pull up the Find in Files dialog
Enter your search variable name and scope (document, project, solution etc)
Find all
Scroll to the bottom of the resulting Find Results and you'll see Matching lines: xxx

Save searches in Visual Studio

Is there a way to save a search information in Visual Studio. For example if I'm constantly searching for "This string", match case, match whole word, look in 'Current Project'. Can I store this somehow as a saved search?
This is easy to do with a macro. Start with Tools + Macros + Record. Do a search, setting all the options you want, click Stop Recording. View + Other Windows + Macro Explorer. Rename the "TemporaryMacro" to something more suitable. Tools + Customize + Keyboard and assign a keystroke to the macro.
You now have a single keystroke to execute the search.
I found that if you do the following in VS2012:
1) Copy and paste the file types list back into the "Look at these file types" search box
2) Click and unclick the "Use Regular Expressions" checkbox
3) Press "Find Next" before "Find All"
4) Close visual studio and reopen the solution
For the actual search string I think if you make sure your cursor is positioned on a blank line, it will also reuse the last search string, otherwise it will pick the string under the cursor.
Then (at least VS2012) will remember the last search options. You may or may not also need to click your heels and perform some voodoo magic that i was doing at the time on the side (that part is a secret, sorry)

Visual Studio keyboard shortcut to scroll method overloads tooltips?

Does anyone know what the keyboard shortcut to scroll a method's overloads that appears in the tooltip is? I presently have to resort to using the mouse to click the ^ and v labels in the tooltip, which isn't particularly effective.
Thanks!
A little late but maybe somebody else needs it too:
Place the cursor after the first bracket
Press Ctrl + Shift + Space
What's the command to bring up the tooltip? I know the shortcut in Eclipse (Ctrl + Space) but that's Eclipse...
In VS the tooltip shows when you type the first bracket but if I would like to see the different method overloads for a method that's been implemented already, how would I do that?
Press Ctrl + Shift + Space to see the list of overloads and arguments.
See the Visual C# 2008 Keybinding Reference Poster for more keyboard shortcuts.
The arrow keys work for me...
Sometimes I have to hit escape to get rid of the intellisence popup before using the arrow keys to scroll through the overload list.
What's the command to bring up the tooltip? I know the shortcut in Eclipse (ctrl+space) but that's Eclipse...
In VS the tooltip shows when you type the first bracket but if I would like to see the different method overloads for a method that's been implemented aldready, how would I do that?
There's got to be an easier way than this:
place the cursor just after the first bracket
erase it
re-type it (tada!)
navigate the methods using up and down arrows
when you're done, press ctrl+z to undo changes.
1. To Show Overloading Suggestions
Place the cursor after the first bracket and press CTRL + SHIFT + SPACE to bring it back.
Also, Erasing the opening bracket and writing it back can do the trick too.
2. To Scroll through Overloading Suggestions/Options
if your IntelliSense options are showing then press ESC which will hide it. Now, it's time to use the Up/Down arrow keys to see the charm.
if your IntelliSense is disabled, the Up/Down arrow keys will work directly.
Ctrl + Shift + Space in the "()" method brackets brings up the method overload context menu. The UP and DOWN arrows are used to navigate through.
The Visual Studio Keybindings definition is : Displays the name, number, and
type of parameters required for the specified method.
P.S. Jasper's link to Visual C# 2008 Keybinding Reference Poster is useful, check it out.
Arrow keys are the short cut keys i suppose as they work for me.
You can type a comma after the last parameter of the function. That will bring up the intelisense menu

Resources