Vim regex equivalent in vs code - regex

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.

Related

migrating from MFC C++ 6.0 application to VS 2005

I have a big application developed in MFC C++ 6.0 and I want to migrate it to VS2005 and then, to VS2012. I'm looking for solve as much errors as I can, however I run into this situation:
I had a MFC C++ method: BOOL CPaginaModelo::OnRetirar_ItemLista() which returned a boolean value. So in many cpp files I use code like:
if (CPaginaModelo::OnRetirar_ItemLista())
{
<code>
}
For migration reasons, I have to change such method from BOOL to void, so the code should looks like:
CPaginaModelo::OnRetirar_ItemLista();
<code>
Since there are a lot of parts of the project files where this is used, is there any way by using search and replace with regular expressions in VS2005 to replace first expression to look like second expression?
Thanks for your help
Find and replace operation is not dependent on visual studio version. If you want use higher version of VS for this purpose then you just need to open particular VS and in find window replace window, replace parameter of "Look In" from entire solution to folder of your solution. This will allow you apply find and replace operation on certain folder.
To solved your issue, Multiline Search and Replace will help to complete replacement of your code with specific.
You could find and replace text in the Visual Studio editor by using Find and Replace (Ctrl+F or Ctrl+H) or Find/Replace in Files (Ctrl+Shift+F or Ctrl+Shift+H). For more details, I suggest you could refer to the link:https://learn.microsoft.com/en-us/visualstudio/ide/finding-and-replacing-text?view=vs-2019
You could also try to use .NET regular expressions to find and replace text in visual studio. For more details, I suggest you could refer to the link:https://learn.microsoft.com/en-us/visualstudio/ide/using-regular-expressions-in-visual-studio?view=vs-2019
As far as I'm concerned, Replacement couldn't make a symbol disappear, so { } may need to be removed manually.

How to find all the #if conditions that surround a given line of C++ code?

I'm trying to untangle some code I didn't write. There are a lot of #if statements nested throughout this long file. I'd like a way to quickly identify all the #if statements that surround a given piece of code. Trying to search the Web for "#if" is hard since that either gets hashtags or ignores the punctuation, and "conditional preprocessor directives" didn't turn up anything other than a description of what they are.
Are there any commandline tools that already exist to find all the #ifs affecting a given line?
I'm using Visual Studio 2015 Pro. Are there any extensions that do that?
Not a proper answer but you can use sublime text editor.
In sublime you can select #ifby pressing ctrl + Done by one.
and if you want to find all press ctrl + f and type #if it will select all.
it want take too long to download it. you can download it from here. it is only about 8 mb in windows.

how to do vi search and replace within a range in sublime text

I enabled vintage mode on sublime text.. but there are some important vim commands that are lacking.. so let's say I want to do a search and replace like so
:10,25s/searchedText/toReplaceText/gc
so I wanna search searchedText and replace it with toReplaceText from lines 10 to 25 and be prompted every time (ie yes/no)..
how do I do this with Sublime Text? everytime I hit : it gives me this funny menu.. any way around that?
If you so much would like to see vim in action, try the other way around; ie enable sublime stuff in vim.
Here are 2 links that might come in handy:
subvim and vim multiple cursors (Which is one amazing feature in sublime that lacks in native vim).
Hope that gets you creative ;)
Unfortunately vintage mode does not understand ranges. The best way I know how to do this is with incremental search:
highlight the first occurrence of searchedText on line 10
hit cmnd/ctrl D to have Sublime find the next occurence
If you you want the next occurrence ignored, hit cmnd/ctrl K
Once you have highlighted all the occurrences, you can replace them all at once, as Sublime has left cursors behind on every occurrence you opted in on.
VintageEx gives you a Vim-like command-line where you can at least perform substitutions. Well, that's how far I went when trying it. I don't know how extended the subset of Vim commands it implements is but I'd guess that it's not as large as the original and, like with Vintage, probably different and unsettling enough to keep a relatively experienced Vimmer out.
Anyway, I just tried it again and indeed you can more or less do the kind of substitution you are looking for, which instantly makes ST a lot more useful:
:3,5s/foo/bar/g
:.,5s/bar/foo/g
:,5/foo/bar/g
:,+5/bar/foo/g
Unfortunately, it doesn't support the /c flag.
a plugin named vintageous offers more features including search function. It's available in package control
although this question is answered.. i figured this would add some value
the full functionality of vi search/replace is possible with the ruby mine IDE, once you install the ideavim plugin. The idea is perfect for ruby on rails by the way.

Making Dreamweaver more like Notepad++

I'm moving to Dreamweaver from Notepad++, and while Dw does have many better features than Notepad++, there are a few that I'm really missing.
Is there a way to make the "Home" key on the keyboard take you to the front of where the code starts, instead of the very front of the line? In Notepad++ this is how it works by default, and I don't know why anyone would want to go to the very front of the line instead of the front of the code. I use tabbing to keep it more organized, so this feature is really important to me.
How do I duplicate a line in Dw? In Notepad++ I can select the line and press ctrl + d and it automatically duplicated the code. This is awesome for something like a gallery or a table where I don't want to have to type out every line because it's so similar.
Less important, as I don't use this that often, but can you vertically select in Dw? In Notepad++ you can hold down alt and select lines vertically. Ex:
http://dl.dropbox.com/u/12147973/vert-select.jpg
Thanks in advance.
For #2, check out the Code Extras extension for Dreamweaver
No Longer works in DW5.5; Try here - http://yoropan.com/en/archives/544
I was also wanting some of this features... I discovered that, at least in CS6, #2 is already in Dreamweaver, but the shortcut is Ctrl+Alt+Down ou Up, depending on the direction that you wanna duplicate the code.
Note that I had to disable the shortcut that turns your screen view for that to work. (It's an intel default, press Ctrl+Alt+f12 to open the options)
And tãa dãaa... IT WORKS! :D
I want to say one thing different. My Dreamweaver theme (Users who use Dreamweaver after use Notepad++). Download Dreamweaver.xml
"Dreamweaver.xml" file is in here for windows: C:\Program Files\Notepad++\themes\Dreamweaver.xml
The answer to #1 = Ctrl+Home in anything in windows will take you to the absolute start of the documents, same as Ctrl+End, Home and End to start and finish of lines, Ctrl+Left or Right arrow to jump entire words...
I too am on the quest for duplicating lines in DW. #3 your image no longer shows.
If I want to duplicated a line I click on the line number, then CTRL+C to copy and CTRL+V to paste. Is that what you're looking for or am I being simple?

RegEx to match C# Interface file names only

In the Visual Studio 2010 "Productivity Power Tools" plugin (which is great), you can configure file tabs to be color coded based on regular expressions.
I have a RegEx to differentiate the tab color of Interface files (IMyInterface.cs) from regular .cs files:
[I]{1}[A-Z]{1}.*\.cs$
Unfortunately this also color codes any file that starts with a capital "I" (Information.cs, for example).
How could this RegEx be modified to only include files where the first letter is "I" and the second letter is not lowercase?
Your regexp should work as it is. It is possible that it is executed in ignore case mode. Try to disable that mode inside your regexp with (?-i):
(?-i)[I]{1}[A-Z]{1}.*\.cs$
Try this
"(?-i)^I[A-Z].*\.cs$"
Sets case insensitve off first.
Regular Expression Options
Filenames in Windows are not case-sensitive, so obviously Power Tools will be using case-insensitive matching.
How about this:
^I([A-Z][A-Za-z0-9]*){1}\.cs$
so
IMyInterface.cs // matches, MyInterface
IB.cs // B
IBa.cs // Ba
IC1.cs // C1
I.cs // don't
Information.cs // don't
Prooflink
I based mine off the default patterns placed in there and used ^I[A-Z].*\.cs[ ]*(\[read only\])?$ - I think that there is a precedence question, though, so that if you leave the default .cs pattern matcher in there and add yours to the end, you might have yours hidden, because it matched the general one first.
And you can't re-order or delete them, so it's a little fiddly to get the ordering working well ...
FWIW, I don't think the case-sensitivity question ((?-i) makes any difference.