Replace text only in one part of a page in Visual Studio 2012 - visual-studio

I want to replace a word only in one particular paragraph of a .cs page. I select the paragraph, but when I go to find and replace the text get deselected and the word is highlighted everywhere on the page and not only in that paragraph. Is there a way to achieve what I want in VS or should I just copy the text in another page/text editor and do the replacing there?
Thank you.

Select the text, press Ctrl+Shift+H, make sure "Selection" is selected in the "Look in" window. While the Find and Replace window is open you should be able to select whatever you want from your code window and the original selection should not change. Copy what you want to replace and paste to Find what window. Set "Replace With" window with the text to replace and click the "Replace All" button.

Related

Jump back to previously edited line/word within word document

While editing / reviewing a large word document (doc/docx) document, I was searching for a way to jump back to the previously edited text or line but couldn't find any button enabling me to do so.
Has anybody a solution for this?
You can use the predefined commands "Next Edit" and "Previous Edit". You can for example add these commands in one of the tabs of the ribbon.
For this, right-click the ribbon and select "Customize the Ribbon..."
Select to chhose the command from "All Commands" and use the right-hand side to define where the buttons for the commands shall be placed:

Shortcut to move cursor to input text in Find Navigator-Xcode 6

What is the shortcut to move cursor to input textfield in Find Navigator in Xcode?
For example, there is a image and I want to find where the image is used in Xcode project. I copy the image's name in Project Navigator (Cmd+C), then move to the Find Navigator (Cmd+3). I want to know shortcut to move cursor to input text field instead click mouse to the text field.
Does anyone know what the shortcut is? Thank you.
After you press CMD+3, try SHIFT+TAB once or press TAB three times. Let me know if it works

Is there a way to create a hotkey to print a specific string in xcode?

Is there a way to create a hotkey to print a specific string in xcode?
For example if "H" is my hotkey, every time I click "H" it should paste "Hello" on my editor.
This would help when inserting standard fixed comments when coding.
Thanks in advance.
It's easy to do it with Xcode code snippets. First you need to create a content (your comment or code or both). Select your content by dragging mouse on it. Release your mouse then click again on the selected part of text for a second. While holding, your mouse cursor symbol will change to the pointer symbol - drag this content to code snippets library. Xcode will create new code snipped for you. It will be placed at the bottom of all snippets in snippets library with the name "My Code Snippet". Double click it. Then press "Edit" button. Name it in the field "Title". Write summary you want. Choose platform "All" or "iOS" or "OS X". Select add completion shortcut for example "hello" for "//hello comment". Once you've done with all changes press "Done" button. Every time you will write "hello" Xcode will show a pop up with snippet title you have created. Select it and press "Enter" key and your comment will be placed right there where you wrote "hello".
Animated gif shows how you can do this:

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

Shortcut for Replace button in "Find and Replace" dialog

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).
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.
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
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.
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.
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

Resources