• MultiLine Replace (multiple hosts in hostsfile)

    Locked
    12
    0 Votes
    12 Posts
    5k Views
    guy038G

    Hi, @rugabunda, @scott-sumner, @dinkumoil and All,

    Ah, many thanks, Dinkumoil, for your optimization advices !

    Of course, having 17,000 messages “impossible to open File-B.txt” is rather idiot ! I did not realize this, as working on my tiny File_A.txt :-(

    Thus, appending 17,000 times, a line to File_C.txt is not very efficient, too, as you said !

    Finally :

    If you previously chose some basic filenames, without spaces, this syntax should be enough : (for /f "delims=" %L in (File_A.txt) do @(findstr /x /c:"%L" File_B.txt 1>NUL 2>NUL || echo %L)) > File_C.txt If your filenames may be long, with some space characters, the @dinkumoil solution, with the usebackq option and filenames surrounded by double quotes, is safer !

    Cheers,

    guy038

  • Can't save file with name of already opened file

    Locked
    4
    0 Votes
    4 Posts
    4k Views
    Scott SumnerS

    I see no sanity in a feature request that would bring back the 7.4.2 behavior. It seems like this behavior is just “asking for trouble”.

  • Notepad++ 7.5.8 - x64bit compatible with ThinApp sequencing or not?

    Locked
    1
    0 Votes
    1 Posts
    711 Views
    No one has replied
  • Folding: Newlines & tabs

    Locked
    1
    1 Votes
    1 Posts
    625 Views
    No one has replied
  • Save failed: Please check if this file is opened in another program.

    Locked
    1
    0 Votes
    1 Posts
    2k Views
    No one has replied
  • Where is the version of Notepad++ for Android oficial?

    Locked
    4
    0 Votes
    4 Posts
    2k Views
    elena simonsE

    thanks, too, this problem arose…

  • How to generate random numbers beetwen 1-5?

    Locked
    2
    0 Votes
    2 Posts
    2k Views
  • making a list of URLs?

    Locked
    2
    0 Votes
    2 Posts
    898 Views
    Jim DaileyJ

    I wouldn’t attempt to do this with an editor. I would use a scripting language. For example, in AWK:

    BEGIN { Text="http://www...offset=" Offset = 20 for (i = 1; i <= 2000; i++) { printf("%s%d\n", Text, Offset) Offset += 20 } exit }
  • Double-clicking a file keeps opening new Notepad++ instances endlessly

    Locked
    1
    0 Votes
    1 Posts
    724 Views
    No one has replied
  • Find a line and copy the next 10 lines

    11
    0 Votes
    11 Posts
    26k Views
    guy038G

    Hello @ankur-sharma, @terry-r and All,

    I’m thinking about a very easy solution, with a regex S/R, which does… all the job :-))

    So, let’s imagine the initial text, below :

    This a some dummy text to fill up the zone line 1 line 2 insert_job:AB line 1 line 2 line 3 line 4 line 5 line 6 line 7 line 8 line 9 line 10 This a some dummy text to fill up the zone line 1 line 2 insert_job:AB line 1 line 2 line 3 line 4 line 5 line 6 line 7 line 8 line 9 line 10 This a some dummy text to fill up the zone

    Now :

    Open the Replace dialog ( Ctrl + H )

    Select the Regular expression search mode

    Tick the Wrap around option

    SEARCH (?s).*?(?-s)((?:^.*\R){2}insert_job:AB\R(?:^.*\R){10})|(?s).+

    REPLACE ?1\1\r\n

    Clic on the Replace All button

    Et voilà !

    You should get, as below, the two expected areas of text, separated with a line-break ;-))

    line 1 line 2 insert_job:AB line 1 line 2 line 3 line 4 line 5 line 6 line 7 line 8 line 9 line 10 line 1 line 2 insert_job:AB line 1 line 2 line 3 line 4 line 5 line 6 line 7 line 8 line 9 line 10

    Notes :

    The main part of this regex is (?:^.*\R){2}insert_job:AB\R(?:^.*\R){10}, which matches :

    2 complete lines with their line-breaks, in a non-capturing group. So, (?:^.*\R){2}

    The complete line insert_job:AB, with its like-break. So, insert_job:AB\R

    10 complete lines with their line-breaks, in a non-capturing group. So, (?:^.*\R){10}

    As this main part is embedded in parentheses, it’s stored as group1, for further use , in replacement

    The part (?s).*?, at beginning, matches all the multi-lines stuff which precedes the main part

    When no more main part can be found, the regex engine tries the second regex (?s).+, placed after the alternation symbol ( | )

    This second regex matches all the remaining characters, after the last block of lines to keep till the very end of the file

    Note that, if the string insert_job:AB is part of a line, you must change the part insert_job:AB\R with .*insert_job:AB.*\R

    Remark : The method consists to use the following generic regex :

    SEARCH (?s).*?(Your regex to match)|(?s).*

    Refer to this post, for further explications :

    https://notepad-plus-plus.org/community/topic/12710/marked-text-manipulation/8

    Best Regards,

    guy038

  • Changing quotes ONLY within HTML elements

    Locked
    2
    0 Votes
    2 Posts
    802 Views
    guy038G

    Hello, @dario-de-judicibus, and All,

    No problem with regular expressions ;-))

    So :

    Open the Replace dialog ( Ctrl + H )

    Select the Regular expression search mode

    Tick, if necessary, the Wrap around option

    SEARCH (?=[^<>]+?<)(?:(\x{201c})|\x{201d})

    REPLACE &(?1l:r)dquo;

    Click once, on the Replace All button or several times, on the Replace button

    Notes :

    The main part (?:(\x{201c})|\x{201d}), is a non-capturing group with an alternative, |, which looks for, either :

    The LEFT DOUBLE QUOTATION MARK, of Unicode value 201c, stored as group 1, due to the embedded parentheses

    The RIGHT DOUBLE QUOTATION MARK, of Unicode value 201d

    But ONLY IF the condition of the positive look-ahead structure is TRUE. That is to say if the regex [^<>]+?< can be matched at the current position of the regex engine

    This condition represents the shortest range of characters different from the two chars < and >, ending with the < character. Note that the ending < character may, either, introduce an other tag or close the present open tag, with the syntax </

    In replacement, the left or right double quotation mark is, then, changed into :

    An ampersand character &. Then,

    If the \x{201c} character has been found, in the correct area, the group 1 is defined => a l letter follows

    If the \x{201d} character has been found, in the correct area, the group 1 is not defined => a r letter follows

    Finally, the string dquo; is added

    Remark : This regex can, also, manage correct areas, which are split on several lines, like as below :

    <p class=“test”> Change all “this” text to “that” text.</p>

    Best regards,

    guy038

    P.S. :

    Now, if you prefer to search for all the Change “this”. areas, in some HTML code, use the following search regex :

    SEARCH (?![\h\r\n]+)[^<>]+?(?=<)

    Notes :

    The regex [^<>]+?(?=<) tries to match the shortest non-null range of characters, different from the two chars < and >, ONLY IF it’s followed with the < character

    And ONLY IF the negative look-ahead is TRUE at the current regex-engine position. In other words IF the area matched is NOT filled in with, only, horizontal blank and line-break characters !

  • Creating "copy buttons"

    Locked
    9
    0 Votes
    9 Posts
    2k Views
    Scott SumnerS

    @PeterJones

    this may be related to #32

    Ugh, and I looked thru the list before opening #104…double ugh!

  • Exception 'Division by zero' error on start

    Locked
    3
    0 Votes
    3 Posts
    1k Views
    PeterJonesP

    please see FAQ Desk: Request for Help without sufficient information to help you, then come back to this topic and give us enough information to help you.

    For what it’s worth, with NPP 7.5.8 32-bit installed or 64-bit standalone (both of which I’ve used frequently in the last couple days), I have not seen the problem you are describing. My guess is that it’s a plugin causing your issue… if you read the FAQ, and provide the ? > Debug Info, along with other relevant information, someone might be able to help you. But, as it is, all I can say is “it doesn’t happen for me”.

  • Need regex for incremental by 1

    Locked
    8
    0 Votes
    8 Posts
    12k Views
    Scott SumnerS

    @Vasile-Caraus

    It sure seems like you could use a variation on the technique described above:

    key concept: use Replace All in All Open Documents or Replace in Files for most of the action create a delimiter and a lookup-table running from 0 to 101 (or whatever), probably all on one line is best, e.g. \r\n-----0:1,1:2,2:3,3:4,4:5,5:6,6:7,7:8,8:9,9:10,10:11,… ; you can do this with the column-editor features to ease the pain…followed by some editing… regex replace \z in each file with the lookup table string created above (this will add the table at the end of each file) run a regex replacement (on all files) like described above for the other poster but customized for your data, e.g. \$item_id = \d+; and the contents of the lookup-table string craft another regex replacement to remove the delimiter and lookup-table from all files
  • Sorting lines evenly in document

    Locked
    3
    0 Votes
    3 Posts
    1k Views
    Scott SumnerS

    @David-Talbot

    Although it doesn’t help with the fixed-interval distribution, these links might assist with doing some random “sorting”:

    https://notepad-plus-plus.org/community/topic/14129/sort-file-removing-duplicates-possible (this is a base link which doesn’t discuss random sorting per se, but it leads to the following link, which offers it as a feature)

    @Claudia-Frank 's “Sorter” Pythonscript: https://gist.github.com/ClaudiaFrank/3b5a346b86b5391c67f2f96845ff7ecd

    Really though, the OP is a rather specific and esoteric need…and that usually ends up with someone telling you to not depend upon Notepad++ being able to help, but rather grabbing a programming language of your choice and “having at it”.

  • Programming language not being saved.

    Locked
    2
    0 Votes
    2 Posts
    802 Views
    gstaviG

    Notepad++ is used to edit plain text files.
    A syntax highlighting lexer can be applied to the text file so it will be displayed with colors.
    Notepad++ tries to guess the appropriate lexer from the file extension. Usually it works since extensions are tightly coupled to language.
    If it does not then the lexer can be manually selected from the Language menu.
    In any case nothing related to Language is ever ‘saved’. Notepad++ only saves the file’s plain text. If your file’s extension is not associated to your desired language then you will have to manually select the language every time you open the file.

    If you need to add or fix file extension association to language it can be done from: Settings -> Style Configurator
    Select the language and observe: Default ext and User ext.

  • Deleting multiple lines that contain a certain text

    Locked
    6
    0 Votes
    6 Posts
    2k Views
    Terry RT

    Right, this time I tested it and I think this regex might achieve the correct result. Sorry about the false start. My mind on other matters.

    Find what: ^<passthrumac(?:.+\R){4}.+?>Guest01<(?:.+\R){2}</passthrumac>\R
    Replace with: empty field here <— nothing in this field
    So search mode is “regular Expresssion” and “wrap-around” ticked, nothing else.

    You mentioned Match Case. You could tick it if you ONLY want exactly the text portions as typed in the Find what field, so <passthrumac>, rather than say <PassThruMAC>, and Guest01 rather than guest01. Otherwise I’d leave it unticked.

    Again, sorry, have a go with this and let me know.

    This regex expects EXACTLY 7 lines, hence I removed the (?s) from the first incorrect one. So the lines must be in the same order as you show. That’s why I only check for >Guest01< rather then look for <username>Guest01</username>. So it cannot confuse Guest01 on that line instead of the following Guest01 with the Auto-added string in front.

    Terry

  • Is it possible to set and save style tokens in a notepad++ file?

    Locked
    2
    0 Votes
    2 Posts
    3k Views
    Scott SumnerS

    @Douglas-Kaynor said:

    Is it possible to set and save style tokens in a notepad++ file?

    Not currently, although if you are ambitious you can do it with some scripting

    possible future feature?

    You can ask; sure seems like this might have been requested before, try searching the issues list…

  • 2 Votes
    6 Posts
    16k Views
    PeterJonesP

    There is the old (read-only) Notepad++ Wiki: it’s years out-of-date, but some of the basic information is still useful. (For example, the Wrap around is mentioned briefly on the Searching And Replacing page.)

  • BUG: Normal Text always highlighted

    6
    1 Votes
    6 Posts
    7k Views
    Adam CorballyA

    Hello to anyone who may eventually run into the same problem. Like Mike said, the issue is the NPPCalc.dll plugin, but its not actually a bug, its a feature, activated when you press CTRL + SHIFT + C, which can only be disabled by pressing the button sequence again and changing tabs to force it to reload.

    Highly irregular, and its been plaguing me for years! Hopefully that helps someone else