Visual Studio - How do I hide all occurrences of a text in a file - visual-studio

Is there a way to hide all occurrences of a text in a file? I would rather avoid Macro extensions since I did not find one to match the features of the old, built-in Macro Editor.
Thank you.


Multiline Find & Replace in Visual Studio

Can it be done? We're using VS2005 and VS2008 and VS2010.
I don't mean regular expressions - which have their place - but plain old text find & replace. I know we can do it (at a pinch) with regular expressions using the \n tag but prefer not to get tangled up in regex escape characters, plus there's a readability issue.
If it can't be done what plain and simple (free) alternative are people using? That doesn't involve knocking up our own macro.
I finally found it..
No need to download and load any external macro.
Its working in Visual Studio 2008 with in-built macro at least. :)
Steps :
1) Select text you want to find.
2) Press "Alt+F8" or open "Tools -> Macros -> Macro Explorer"
3) Double click "Sample -> Utilities -> FindLine". (It will open Find box with your selection loaded in "Find" field. Don't worry about truncated text shown in "Find" field. Trust me, field has it all..MS way of showing it may be... :) )
4) Click on "Quick Replace" button on "Find And Replace" dialog box. Enter your replace with text.
5) And Click any of 3 buttons as per your requirement...and its done. :)
Hurray.. its working.. May not be a straight forward way to do it but you know with MS.. nothing is straightforward and easy.. :)
You might want to take a look at this blog entry:
Multiline Search and Replace in Visual Studio
Provides macro code to escape your search and show the VS find and replace dialog.
This works today in Visual Studio 2012:
See how the (.*\n)+? part does the match across multiple lines, non-greedy.
fooPatternToStart is some regex pattern on your start line, while barPatternToEnd is your pattern to find on another line below, possibly many lines below...
Example found here.
Simple and effective :)
Note: before VS2012, the pattern that worked was: fooPatternToStart.(.\n)+#.*barPatternToEnd
You can search for multiline expressions by clicking on the "Use Regular Expressions" checkbox in the "Find and Replace" dialog. Line breaks are then indicated by \n.
I use this:
Visual Studio Gallery Multiline Search and Replace
You could also open the files with UltraEdit which fully supports MultiLine replace.
You can use the trial version if you only intend to use it once.
Regarding the comment of Andrew Corkery Aug 19 '11 at 9:52 above:
If you like to specify a multi-line replacement string as well, edit the macro code and set the replacement text as shown below.
This will allow you to "fine-tune" your replacement with just the small modifications needed.
Sub FindLine()
Dim textSelection As TextSelection
textSelection = DTE.ActiveDocument.Selection
DTE.Find.FindWhat = textSelection.Text
'also preset replacement text with current selection
DTE.Find.ReplaceWith = textSelection.Text
End Sub
Its provided by microsoft only. Please check
It uses regular expression only. But for those who don't know regex better to use it.
The latest version (as of this posting) of Notepad++ does multi-line find/replace. I don't know if this was true back when this was asked. But with no macro support in Visual Studio anymore, this is relevant now.

How can I enable autocomplete text support in Notepad++

There's already a question on this here. But i want to know if its possible to add autocomplete text support in a .txt file for english words (maybe from GNU Aspell dictionary)?
Something I've pondered myself, you could copy loads of "words" into the keyword list within the user-defined language dialogue. Not the best way!
If you have a look at the XML file in (vista);
Then you can see keywords are kept in one line. I bet, if you made have the entire english dictionary then it would likely crash notepad++.
You could put your idea into the Notepad++ IdeaTorrent for the developers too consider;
UPDATE 06/11/2011 :
May I also add that a plugin now available for highlight misspelt words and auto correction.

Vim regex equivalent in vs code

In Vim I can use :g/^\s*T\y A to copy all lines starting with T in a file to register a, then paste it to wherever I need it from said register.
How can I, or what is the equivalent regex to do the same in Visual Studio Code?
Be mindful that I am NOT fluent with regex and two days new to VS Code.
Thanks for your help in advance.
I don't think you can copy to multiple registers like that in VSCode unless someone has an extension to do it. Otherwise, one at a time you can:
Put ^\s*T.*$ in the search field
ALT-Enter will select all occurences of those matches
CTRL-C to copy to clipboard
Then paste to where you want it.

Change the text cursor/caret in Visual Studio 2010

I've accidentally changed the text cursor/caret in Visual Studio 2010 from the line to the one with the box that highlights the entire character and cannot find out how to change it back.
Can anyone tell me how?
Press the Insert Key
To clarify there are two modes when using the editor: Insert and Overwrite.
Insert -- the "normal" thin caret that inserts characters as you type.
Overwrite -- the "fat" caret that will overwrite any previous characters as you type.
These two act the same when at the end of your document and you are just typing but go in the middle of some text and use them then you will see the difference.

Is there a Windows utility that will let me do multiple programmatic find/replaces on text that I cut & paste into it?

I've inherited some C# code that contains about a thousand lines of source that I need to modify, transforming it from this:
newDataRow["to_dir"] = comboBox108.Text;
To this:
assetAttributes.Add("to_dir", comboBox108.Text);
The lines occur in various places throughout the application in groups of 40 or 50. Modifying each line by hand in Visual Studio 2008 can be done but it's labor intensive and prone to errors.
Is there a Windows utility out there that will let me cut and paste groups of code into it and then run some sort of reg-ex expression to transform the individual lines one-by-one? I'd also be willing to use some sort of VS 2008 add-in that performed the same set of reg-ex operations against a selection of code.
Thanks in advance.
If you simply want a text editor that can do this, you might want to try PSPad - the find/replace allows for regular expression useage.
While not a great experience, you can use the VS2008 built-in search & replace to do this.
Note that it has its own regex syntax. To do this, go to Edit | Find & Replace | Replace in files. Then expand "Find Options" and select use regular expressions.
Try this - test and fix... For your search term, use
newDataRow\[{"[."]*"}\] = {[^;]*}
and replace with
assetAttributes.Add\("\1", \2\);
The \1 and \2 identifiers are the first and second groups (surrounded with {}) that were found. hit the arrows next to the search terms for a menu, select the botom option to go to help.
In Visual Studio, Find and Replace allows you to replace using regular expressions. In the Find and Replace dialog, under Find options, there is a 'Use' checkbox with Regular expressions in it. Use the arrows next to 'Find what' and 'Replace with' to learn about Visual Studio's slightly different syntax.
Using the regular expression search and replace, you can search for:
newDataRow\["([a-zA-Z_]+)"\] = comboBox([0-9]+).Text;
and replace with
assetAttributes.Add("\1", comboBox\2.Text);
which should do the trick :o)
Windows Grep is great, and should do exactly what you want, and more:
My choice of tool in this matter would probably be Notepad++ (Search/Find in Finds - does replace too). Supports RegExps.