Insert before/after on lines

  • putter1900

    putter1900 - 2012-04-11

    Good afternoon,
    Just recently adopted N++ and it's already proven itself several times over. What I can't find in any documentation though is the ability to "insert" stuff before (and after) the end of a line

    I have a list of IP's like this

    What I want to do is:
    a) insert this at the start of every line
    -A INPUT -s
    b) insert this at the existing end of each line
    -j DROP

    so that the finished result looks like this;
    -A INPUT -s -j DROP

    Any guidance or help would be greatly appreciated!

    Regards & TIA


  • Michael Guidry

    Michael Guidry - 2012-04-11

    Try using the Macro for this.
    Place the cursor to insert at the beginning of the first IP address.
    Select menu item: Macro>Start Recording
    Enter the pre-fix "-A INPUT -s "
    Select the 'end' key to move to end of line.
    Enter the post-fix " -j DROP"
    Select menu item Macro>Stop Recording
    Re-run the macro through the list by selecting menu item Macro>Run the Macro Multiple Times.

    Hope this helps.


    THEVENOT Guy - 2013-03-10

    Hello putter1900,

    By now, I guess you should have find a solution !

    So, just for fun,

    If you have Notepad++, since the 6.0 version, it's quite easy !

    No need for scripting !

    • Select your file, containing IP addresses

    • Go back to the BEGINNING, with the CTRL + Home shortcut

    • Open the SEARCH-REPLACEMENT dialog, with CTRL + H shortcut

    • Type in SEARCH             .+

    • Type in REPLACEMENT     -A INPUT -s $0 -j DROP

    • Select the "Regular expression" search mode

    • Select the "Wrap around" box

    • Click on the "Replace All" button

    That's all !

    .+ , in SEARCH means ANY character, repeated, at least one time

    $0 , in REPLACEMENT stands for the totality of the SEARCH string

    Best regards,


    Last edit: THEVENOT Guy 2013-03-10