Menu

Search & Replace for more than 1 line

2007-05-10
2012-11-13
  • Nobody/Anonymous

    Hello,

    I know it is possible to search and replace for more than 1 line with Ctrl+R but only for one file. How can I do the same thing for several files? Is there a way, like a plugin or something like that ?

    Thank you.

     
    • pshute

      pshute - 2007-05-13

      Control+H does have some very limited multiline capabilities. See http://notepad-plus.sourceforge.net/uk/site.htm for details.  I've never tested these with the "replace in all open documents" function.  It certainly doesn't let you operate on unopened files like control+F does.

      If that's not satisfactory, I have used a command line program called msub for years for this kind of thing.  It allows you to do regexp search and replace on files.

       
      • Mieszko Lassota

        Mieszko Lassota - 2007-05-14

        this is a few lines of code in any script language eg perl:

        -- cut here --
        use warnings;

        $what = shift;
        $to = shift;
        @files = @_;

        foreach (@files)
        {
           open(INFILE, "$_");
           $content = join("\r\n", <INFILE>);
           close(INFILE);

           s/$what/$to/g;

           open(INFILE, ">$_");
           $content = join("\r\n", <INFILE>);
           close(INFILE);
        }
        -- cut here --

        ofcourse this is a bit lame (eg. you have to specify the whole path for each file, the file is opened twice, the eol is lost etc.) but what do you expect from 2 min script... and you have regex support out of the box :p

        would be nice to have some script support in notepad++, nothing too advanced, some variables, some text replace, some output parsing... this could be achieved with NppExec, but it needs some work... would be nice to have some kind of macro & scripts window like 'favourites' or maybe add it to favs... anyway... Don... think about it - i can say that if this feature will evolve i can make some perl scripts on demand :)

         
    • Nobody/Anonymous

      It would be cool if someone make multioline search in Ctrl+F. This Ctrl+R works bad for me. I don't khow why, i just can't explain, just bad...

       
      • pshute

        pshute - 2007-05-18

        It can be done in a very limited way in the simple search (control+f).  See http://notepad-plus.sourceforge.net/uk/site.htm for details, but I'd expect to find it not good enough.

        The main problem I've had with the advanced search (control+r) is that if I have anything selected when I invoke it, the Selection option is automatically ticked.  Then everything I do only operates on the selection.  If that's not what one wants or expects then it would appear not to work at all.  Could that be your problem?

        It's really worth finding out how control+r works if you want to work with newlines.  I've found that it's nearly pointless trying to work with newlines and regexp though.

         
MongoDB Logo MongoDB