Shortcut for Replace button in "Find and Replace" dialog
Asked Answered
K

5

12

I call up Find and Replace dialog with Ctrl+H. On F3 it finds the result but then I must hunt the Replace button using the mouse. And on every new find, it changes the screen position. Is there any way to use this dialog using only keyboard?

It will save me a few precious seconds multiplied by some very large number (I'm in the middle of heavy refactoring).

Karenkarena answered 3/11, 2010 at 14:21 Comment(2)
Try to use refactoring feature if available, like renameGoogolplex
Resharper or something similar might be the way to go if you do a lot of refactoring. Alternatively, you could learn Visual Studio Regular Expressions. They are not that dissimilar from PCRE. Also, if you need help learning regex, LinqPad is a useful tool for testing REs (only the PCRE style ones I think, but again the syntax isn't that different).Brenza
E
3

Sorry,

As microsoft there is no keyboard shortcut as Replace Next,

You can check this url

http://msdn.microsoft.com/en-us/library/da5kh0wa.aspx

Eachelle answered 3/11, 2010 at 14:34 Comment(0)
K
22

In visual studio 2015:

  • Ctrl+H opens the Replace dialog.
  • Ctrl+F opens the Find dialog.

Within that dialog:

  • Alt+N - Focus "Find" entry field
  • Alt+P - Focus "Replace with" entry field
  • Alt+C - Toggle Match Case
  • Alt+W - Toggle Whole Word
  • Alt+E - Toggle Regular Expressions
  • Alt+L - Open "Look In" dropdown list. Use Up/Down and Enter to select from this list:

    • Current Block
    • Selection
    • Current Document
    • All Open Documents
    • Current Project
    • Current Solution
  • Alt+R - Replace Next

  • Alt+A - Replace All

  • Esc - Dismiss dialog

For example, to replace "foo" with "bar" within the current selection:

  • Ctrl+H - Opens the Replace dialog, with focus on "Search Term".
    • Enter "foo"
  • Alt+P - Focus is now on "Replacement Term"
    • Enter "bar"
  • Alt+L, choose "Selection", press Enter.
  • Alt+W - Whole word only
  • Alt+R - Replace first term
  • Esc - Close replace dialog.
Kenweigh answered 15/12, 2016 at 11:45 Comment(1)
This is the answer. Now I just need to figure out how ReSharper screwed up my Alt-R (Replace Next).Settle
E
3

Sorry,

As microsoft there is no keyboard shortcut as Replace Next,

You can check this url

http://msdn.microsoft.com/en-us/library/da5kh0wa.aspx

Eachelle answered 3/11, 2010 at 14:34 Comment(0)
B
2

You could simply copy your desired replacement text before starting to F3 through your source text, and hit Ctrl+V when you hit the next match as VS selects the match text for you.

It is a hack, but it works.

Brenza answered 26/4, 2012 at 14:15 Comment(0)
S
2

If you dock the find/replace window then it will not move with each new find.

You can then alternate with 1 finger on F3 to move to next find, while hovering the mouse over the non-moving replace button to replace what you need.

Smothers answered 30/5, 2013 at 3:12 Comment(0)
B
2

It is possible to deactivate Resharper default behavior of "Alt+R" which provides a quick access to Resharper menu in Visual Studio.

Just uncheck it in Resharpers options: enter image description here

Boldface answered 16/8, 2019 at 7:16 Comment(1)
This is the real reason in my case why the shortcut doesn't work anymore.Lorusso

© 2022 - 2024 — McMap. All rights reserved.