tags:

views:

6544

answers:

4

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
+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
I think ^.*#region.*$ will work
Jacob
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
use extended search for replacing escape sequences (radio button just above regex)
John T
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
If you typed the document on windows, line endings will be \r\n. UNIX style line endings are \n.
John T
Duh! that was it. Thanks !
Rismo
Also just noticed that TextFx -> TextFx Edit -> Delete Surplus Blank Lines does the same :)
Rismo
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
+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
A: 

I want to delete line 3 to line 15 across many files (about 100+ files) how should I do it in Notepad++ ?

smallcarz
You'll want to post your own question if you need an answer.
Chris