I'm cleaning up some code files (c#) and want to remove the regions. And what I would like to do is delete all the lines that have the string '#region'. That's just an example, I can think of several more uses, but is that even possible?
A:
you can try doing a replace of #region with \n, turning extended search mode on.
northpole
2009-05-27 21:47:08
+5
A:
You can use search->replace (CTRL+H)
it has a regular expression feature for replacing. You can use a regex that matches #region as well as whatever else is on the line, and replace it with empty space.
John T
2009-05-27 21:47:42
I think ^.*#region.*$ will work
Jacob
2009-05-27 21:53:59
Thanks, I did that and it works. But now I'm trying to replace \n\n with just one \n but doesn't seem to work, any ideas?
Rismo
2009-05-27 21:59:24
use extended search for replacing escape sequences (radio button just above regex)
John T
2009-05-27 22:05:16
Thanks John. I did that and works for one line break \n, but not for two. I'm searching for \n\n and replacing it with \n, but it doesn't work. Does it work for you ?
Rismo
2009-05-27 22:07:40
If you typed the document on windows, line endings will be \r\n. UNIX style line endings are \n.
John T
2009-05-27 22:12:10
Duh! that was it. Thanks !
Rismo
2009-05-27 22:19:08
Also just noticed that TextFx -> TextFx Edit -> Delete Surplus Blank Lines does the same :)
Rismo
2009-05-27 22:25:34
Thank god for plugins! As you can tell I'm a stubborn programmer who likes doing things the old fashioned and most programmatic way possible.
John T
2009-05-27 22:49:07
+8
A:
I would use Search-> Find: #region then check Mark Line and Click Find All.
This will mark the lines with #region.
Then Search -> Delete Bookmarked Lines
That will delete all the marked lines.
You can also use a regex to search. This method won't result in a blank line like John's but will actually delete the line.
Ray
2009-05-27 22:00:30