Menu

Search to select text before external "run"

Keith
2009-01-12
2012-11-13
  • Keith

    Keith - 2009-01-12

    I would like to set up Notepad++ so that I can hit a shortcut keyboard button (e.g. F9) and have Notepad++ then do the following. 

    1.  Search backward (from my current cursor position) and finds a specific set of characters [or the beginning of the file].  Then, it should search forward from that place until it finds that set of characters again [or the end of the file], selecting all text in between these two locations.

    2.  Once this text is selected, it should "run" a command that I have already set up as an External Tool (see http://notepad-plus.sourceforge.net/uk/run-HOWTO.php\
    Obviously, I will be using $(CURRENT_WORD) 

    What I want to do is replicate a behavior from Matlab known as "Cells."   (see http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/matlab_env/brqxeeu-259.html\).  (I will be using a completely different program and program language than Matlab, but this is where I got the idea.)

    Example:

    Suppose I have the following file:

    ---- BEGIN sample.program----

    %% Comment 1
    Code1
    Code2 {location 1}
    Code3
    %% Comment 2
    Code4
    Code5 {location 2}
    Code6
    % Comment 3
    Code7
    Code8
    Code9
    %% Comment 4
    ....

    ---- END sample.program ----

    What I want is to have Notepad++ "Run" the section of code that my cursor is currently in.   My special character group is "%%" to divide by "Cells" of code.  Thus, if my cursor is at {location 1} then I want my keyboard shortcut to "run" all text between Comments 1 and 2.  If my cursor is at {location 2}, then it should "run" all text between Comment 2 and Comment 4. 

    Please let me know how I can do this.  I already know who to set up a "run" shortcut and map it to a keyboard shortcut. I just can't figure out how to get the keyboard shortcut to first do the search. (I presume that you would use a regular expression search to "find" the "%%" dividers in my example above.  The %% is a comment line, so I don't really care if the search includes that text or not.)  I just don't know how to make it happen.

    Many thanks in advance for a little help with this or any pointers or ideas!

    - Keith

     
    • Alexander Iljin

      Alexander Iljin - 2009-01-13

      My idea is: create a plugin for the task. Search operations are not currently supported in macros.