• Wildcard Search

    3
    0 Votes
    3 Posts
    1k Views
    guy038G

    Hello, @peter-mccormack, @terry-r and All,

    Terry, you said :

    We can expand on this and say \d{5,8} which asks for at least 5, and up to 8 digits together, tending to as few as necessary. A further expansion of this is to say \d{5,8}+ which says between 5 and 8 digits but more rather than less, so it’s greedy.

    I’m really sorry, Terry, but your reasoning, about lazy, greedy and possessive quantifiers, is not exact !

    First, if we consider, for instance, the general syntax A{2,9}, this defines 3 types of quantifiers :

    The greedy quantifier A{2,9} which tries to match as many letters A as possible, with a maximum of 9 letters A

    The lazy quantifier A{2,9}? which tries to match as few letters A as possible, so a minimum of 2 letters A

    The possessive quantifier A{2,9}+ which tries to match as many letters A as possible, with a maximum of 9 letters A, but which NEVER allows the regex engine to backtrack so that the overall pattern would match !

    Let’s suppose that our sample text, to test some regex syntaxes, is the simple string AAAAAAAAA ( 9 letters A ), in a new tab

    The regex (?-i)A{2,9}?A matches the string AAA : Logic, because A{2,9}? matches AA, as a lazy quantifier. Then A matches the third A, of course !

    The regex (?-i)A{2,9}A matches all the string AAAAAAAAA. Again logic, but this needs a quick explanation :

    First, the part A{2,9} matches the entire string AAAAAAAAA ( 9 letters ), but, now, there’s NO more text, to satisfy the last part of the regex A

    So, the regex engine backtracks and the part A{2,9} match the string AAAAAAAA (8 letters only ). This time, the reminder of the regex : A can match the 9th letter A !

    The regex (?-i)A{2,9}+A, with the possessive quantifier, matches nothing ! Do you understand the logic of this result ?

    Like above, the part A{2,9}+ matches the entire string AAAAAAAAA. And again, there NO more text which could be matched by A, the reminder of the regex !

    But, unlike the case above, due to the possessive quantifier, the regex engine is NOT allowed, this time, to backtrack. So, as the regex don’t have other alternatives, the regex engine cannot match our subject string and process stops !

    The slightly modified regex (?-i)A{2,8}+A, although containing a possessive quantifier, does match the entire string AAAAAAAAA ! I suppose you’ve already guessed why :-))

    First, the part A{2,8}+ although possessive, matches the string AAAAAAAA ( its maximum : 8 letters ) and the last part A of the regex matches the 9th letter A

    This time, NO need to backtrack : the overall pattern match our subject string AAAAAAAAA

    Keeping again our sample text AAAAAAAAA, let’s test some other regexes :

    The regex (?-i)A{2,9}?A{2,9}?, with two lazy quantifiers, matches the string AAAA ( 2 times the minimum of 2 letters )

    The regex (?-i)A{2,9}?A{2,9}, with a lazy quantifier, followed by a greedy one, matches the entire string AAAAAAAAA ( The first part A{2,9}? matches AA and the last part A{2,9} matches AAAAAAA )

    The regex (?-i)A{2,9}A{2,9}?, with a greedy quantifier, followed by a lazy one, matches, first, all the subject string :

    Indeed, the first part A{2,9} can match all the subject string ( 9 letters )

    As there NO more text for the last part A{2,9}?, the regex engine backtracks 1 position

    So, the first part A{2,9} matches the 8-chars string AAAAAAAA but the last part A{2,9}? cannot match the 9th letter A, as a minimum of two letters A is required !

    Again, the regex engine backtracks 1 position. So the first part A{2,9} matches the 7-chars string AAAAAAA

    This time, the last part A{2,9}? can match the string AA : Done !

    The regex (?-i)A{2,9}A{2,9}, with two greedy quantifiers, matches the entire sting AAAAAAAAA. Logic, as, like above, after two backtracking processes, the first part A{2,9} matches the 7-chars string AAAAAAAA and the last part A{2,9} matches the 8th and 9th letter A, so AA ( UPDATED 07-05-2019)

    The regex (?-i)A{2,9}+A{2,9}, with a possessive quantifier, followed by a greedy one, matches nothing. Why ?

    The first part A{2,9}+ matches the entire string AAAAAAAAA, at the beginning. But, as NO more text can be matched by the last part A{2,9} and that backtracking is not allowed because the quantifier is possessive, the process stops without any match !

    Finally, the regex (?-i)A{2,9}+A{2,9}?, with a possessive quantifier, followed by a lazy one, would produce the same results and gives no match

    You could say : So, what is the benefit of using possessive quantifiers ?

    First, to speed up regular expressions. In particular, they help some alternatives, of your regex, to fail faster !

    Secondly, they prevent the regex engine from trying all possible permutations. This can be useful for performance reasons !

    Thirdly, in case of nested quantifiers, for instance, they may save your day by preventing the regex engine from the catastrophic backtracking event :-((

    One example :

    Let’s imagine the regex (?-i)A*Z, against this sample text AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, in a new tab

    The regex engine, due to the greedy quantifier, will backtrack 50 times to realize that, at any position, an uppercase letter Z cannot be found -((

    Let’s consider, now, the regex (?-i)A*+Z. This time, the possessive part A*+ grabs all the letters A and there NO more text to match the Z regex,. And, as backtracking is not allowed, the regex fails faster and so, the regex engine can search, for other matches, further on, more quickly !

    Of course, you don’t see any difference between the two cases but, for long texts and/or complicated regexes, this may be significant !!

    Finally, here is, below, a summary table of all the quantifiers :

    •--------------------------------------• | QUANTIFIERS | •---------------•----------•------------•--------------• | REPETITIONS | Greedy | Lazy | Possessive | •---------------•----------•------------•--------------• | From n to ∞ | {n,} | {n,}? | {n,}+ | •---------------•----------•------------•--------------• | From n to m | {n,m} | {n,m}? | {n,m}+ | •---------------•----------•------------•--------------• | From 0 to 1 | ? | ?? | ?+ | •---------------•----------•------------•--------------• | From 0 to ∞ | * | *? | *+ | •---------------•----------•------------•--------------• | From 1 to ∞ | + | +? | ++ | •---------------•----------•------------•--------------• | From n to n | {n} | •---------------•--------------------------------------•

    Note that the {n} quantifier cannot be qualified with the flavors Greedy, Lazy or Possessive. It just means exactly n times, the character or expression, right before !

    Best Regards

    guy038

  • Enable Session Snapshot and Periodic Backup Box Unchecked

    19
    3 Votes
    19 Posts
    5k Views
    AndreCunhaA

    I have had this problem for quite some time but have never bothered to go after it.

    Today, after once again losing a few scratch texts because of this ongoing issue, I have found this thread and also a few related open issues on Notepad++ Issues tracker:

    Issue: Default session’s unsaved files are lost (from session’s XML file) after closing Notepad++ in a different session ‘enable session snapshot’ gets disabled occasionally Saved Sessions lost Notepad++ resets my auto-backup setting after I perform a git commit with it. Backup is broken in several ways with multiple instances

    This is particularly unfortunate because Git installer for Windows itself actually offers to set up Notepad++ as the default editor for commits.

    Setting up a portable version just for this seems a bit too much, also it would then be annoying to manually keep both Notepad++ configurations in sync. It is sad, but I have decided to do the same as @Ron-Little and simply use Windows’ Notepad.exe for Git and avoid this problem altogether.

  • Saving a text file as an .html file

    8
    0 Votes
    8 Posts
    2k Views
    andrecool-68A

    @Yangos-Metaxas
    2.276 kb is about 5500 lines with bookmarks)))
    Nobody will fix it for you!

  • Delete line containg a word + previous line

    3
    0 Votes
    3 Posts
    527 Views
    guy038G

    Hello anass-chawki, and All,

    Quite easy with regexes ! So :

    Open the Replace dialog ( Ctrl + H )

    SEARCH (?-is)^.+\R.*/movie/.*\R

    REPLACE Leave EMPTY

    Tick the Wrap around option

    Select the Regular expression search mode

    Click once, on the Replace All button

    Et voilà !

    Remarks :

    If you’re looking for the word movie, in any case ( for instance /MOVIE/ or /MoviE/ ), change the first part of the regex (?-is) with the syntax (?i-s)

    On the other hand, if you want to delete the line containing /movie/ and a true empty line, above, use the syntax below :

    SEARCH (?-is)^.*\R.*/movie/.*\R

    Notes :

    First, the in-line modifiers (?-is) :

    Forces the search to be processed in a non-insensitive way

    Forces to regex engine to interpret any dot ( . ) as representing a single standard character, NOT EOL character(s)

    Then, the part ^.+\R looks for a complete non-empty line, with its EOL characters

    Finally, the part .*/movie/.*\R searches any range, even null, of standard chars .*, followed with the string /movie/, with that exact case, and finally followed with an other range, even null, of standard chars .* and ended with its EOL chars \R

    This selection of complete two lines is, then, deleted, due to the Empty replacement zone

    Best Regards,

    guy038

  • No module named Npp

    32
    2 Votes
    32 Posts
    7k Views
    Alina GubanovaA

    @Alan-Kilborn yep :) well, thanks for your help!

  • Suggestion if it's not possible.

    5
    0 Votes
    5 Posts
    745 Views
    Meta ChuhM

    @Benami-Ark

    i can’t offer ctrl+g, but if you do such searches often, you can give the docked incremental search a shot.
    you can summon it with search > incremental search or ctrl+alt+i.

    keyboard controls: enter = next, shift+enter = previous.
    and if you activate highlight all, you have a nice extra highlighting coloured in blue, which differs from the usual green mouse selection highlighting.

    incremental search screenshot (the little docked search bar at the bottom):
    Imgur

    PS not sure were requests are, but the search function I believe has also been changed to remove the ability for a search to restart at the top once it’s at the bottom of the doc like Microsoft’s notepad which should be change back.

    this option’s default setting never changed, so it might be disabled by accident on your system.
    please activate wrap around at the search/replace panel, as seen at the next screenshot:
    Imgur

    many thanks and best regards.

  • How to set font sizes of the white space character?

    2
    0 Votes
    2 Posts
    1k Views
    Meta ChuhM

    welcome to the notepad++ community, @Wu-Changze

    it is not possible to change the whitespace fonts separately from the text font containing them.
    but maybe @dail 's ElasticTabstops plugin may help you to get some of your documents aligned as desired.
    you can install it via the built in plugins > plugins admin menu in all newer versions of notepad++.

    regarding the usage of fixed width fonts and their spacing differences, it is recommended to use one single font only, and only use colour, bold and italic as highlighting elements, to avoid misalignments.

    many thanks and best regards.

  • Notepad++ stays running after exit

    2
    0 Votes
    2 Posts
    468 Views
    Meta ChuhM

    welcome to the notepad++ community, @major4579

    notepad++ should not stay as an active process when you exit it, except if a plugin prevents a shutdown.

    can you please run notepad++ with the parameter -noPlugin, e.g. by adding -noPlugin to your notepad++ desktop shortcut, or starting notepad++.exe -noPlugin from cmd ?

    also it would come in handy, if you provide us with your debug information by going to the notepad++ menu ? > debug info... > copy debug info into clipboardand pasting it here.

    many thanks and best regards.

  • Python Script support in versions of npp > 7.9.2

    14
    0 Votes
    14 Posts
    3k Views
    YodadudeY

    That worked a treat!

    Thanks.

  • 0 Votes
    14 Posts
    2k Views
    Андрей АпальковА

    @andrecool-68 said:

    @andrecool-68 said:

    У тебя это не нормальное поведение а косяк в коде программы.

    Это понятно, но я устанавливаю стоковые версии, каких-либо правок в коде не делаю
    Спасибо, но это очень трудоёмкая операция, по сравнению с предыдущим удалением

  • Save or store a folder in Recent File List?

    5
    0 Votes
    5 Posts
    670 Views
    andrecool-68A

    @Paolo-Santini104
    Test “Explorer plugin for Notepad ++” it has an option to add to Favorites
    https://github.com/oviradoi/npp-explorer-plugin

  • Run with browsers Missing

    2
  • I can not understand what file opens this option)

    6
    0 Votes
    6 Posts
    806 Views
    EkopalypseE

    @andrecool-68

    because npp has already way to much functionality to remember each of them
    I’m constantly surprised to find a feature builtin to npp which I wrote a python script for.
    :-D

    EDIT: just another wood/tree issue :-D

  • Current line number

    2
    0 Votes
    2 Posts
    634 Views
    EkopalypseE

    @Владислав-Браништи

    no, you can’t do mathematical operations as the variable is a string, not an integer.
    You might use a batch file to do the calc, with something like

    SET current_line=%1 SET /A current_line = %current_line% + 1 echo %current_line%

    and calling from run like cmd /k D:\test.cmd $(CURRENT_LINE)

  • User defined Macros in menu (shortcuts.xml)

    4
    0 Votes
    4 Posts
    951 Views
    Michael VincentM

    @Ekopalypse

    Thanks for the link, very informative. Assuming those are the only “macroable” messages as they may only require a simple wParam / lParam value as that’s all you can supply in the XML macro objects? Seems like the list could be expanded as the one I was quoting - SCI_SETMULTIPASTE (2614) - takes only an integer 0 or 1 for the wParam to turn it on or off.

    I only found out about this feature by reading the Scintilla docs after implementing add to selection via an NppExec script as per your suggestion and adding them to the Macro menu via NppExec.ini. Now when I made a multiple selection with mapped shortcut keys and typed, it all worked great, but using paste (from a previous copied text), it only pasted on the first selected text, not all selections. And that’s because SCI_SETMULTIPASTE is off by default. A quick NppExec:

    SCI_SENDMSG SCI_SETMULTIPASTE 1

    turned it on and then retrying my multiple selection paste worked to paste to all selections! Brilliant!

    So of course I wanted this as a turn on / turn off menu item and thought of the Macro XML in shortcuts because of @guy038 's suggestion. I couldn’t get @guy038 virtual space macro to work (assuming because that’s an enhancement of 7.7.1 and I’m only on 7.7 not using the release candidate), so again, a quick NppExec script:

    SCI_SENDMSG SCI_SETVIRTUALSPACEOPTIONS 5 // for "default" behavior SCI_SENDMSG SCI_SETVIRTUALSPACEOPTIONS 7 // for all on SCI_SENDMSG SCI_SETVIRTUALSPACEOPTIONS 0 // for all off

    and it worked fine for me. So I added the Macros to my shortcuts.xml in prep for the 7.7.1 release and then asked my question about other ‘macroable’ things that I’ve just been doing with quick NppExec scripts using SCI_SENDMSG.

    Just BTW, NppExec (along with I’m assuming PythonScript and LuaScript which I don’t use but see great advice about) are awesome plugins that can immediately extend N++ new Scintilla features even if N++ doesn’t yet have menu items to access them direct. Based on the messages in this form, with NppExec, I’ve added an “add / clear annotation”, “add / clear multiedge”, “add to / add all / remove last from current selection”, the multipaste on/off I discussed in this post … the list goes on …

    @donho thanks for the Scintilla upgrade!

  • NPP crashes when opening UNIX file with "NULL" chars on it

    2
    0 Votes
    2 Posts
    427 Views
    Meta ChuhM

    welcome to the notepad++ community, @Leo-Lagos

    no, notepad++ should not crash, if a file contains 0x00 characters.
    maybe it’s a plugin like the dspellcheck plugin that causes this ?

    please test the following, to verify, if a clean notepad++ (without any plugins that could cause this) would work on your system.

    download the notepad++ 7.7 portable version from >>> here <<<.
    (the portable version does not require any installation and runs completely independent and isolated from your installed version. all custom settings, as well as any stuff you might want to try at the portable version, will not modify your installed version)

    extract npp.7.7.bin.zip to your desktop.

    important note: make sure to close all instances of notepad++ that might be running, before starting the portable version at the next step, to make sure you are using this portable version.

    open the extracted npp.7.7.bin folder and start this portable version by double-clicking on notepad++.exe inside this folder.
    (note: notepad++.exe will just be seen as notepad++, if you have enabled to hide all known file extensions at your explorer settings)

    try to open the original unix file containing 0x00 characters.

    many thanks and best regards.

  • Multiple text and combine in specifique line order.

    4
    0 Votes
    4 Posts
    580 Views
    Terry RT

    @AV-Chan said:

    How can we do this?

    Version 2 of the solution.
    For the files containing text 1 and 2, use the step (i mentioned in first post) to prepended characters for file 2. So both these files will have a number (with leading zeros), both followed by a b character and a space.

    For the regex to apply (after making sure last line is a blank line).
    Find What:(?-s)^(\d+)a.+\R(\1b.+\R)
    Replace With:\2

    We can do this as the 2 lines we are ‘inserting’ will never be in the same location, thus designating differently as ‘b’ and ‘c’ is not required.

    And lastly I’ve also managed to combine to removal of the prepended characters and removing the last line as 1 regex.
    Find what:^\d+[ab]\s|\R\z
    Replace With: <— nothing in this field

    If any issues/queries please do post back. Actually, post back if it all works as planned. We ALL like the warm fuzzy feeling's we get from a good result.

    Terry

  • 0 Votes
    17 Posts
    3k Views
    EkopalypseE

    @andrecool-68
    sometimes I feel the same, but most IT documentation is in English, so … we have to live with it … until the Chinese take over operating system development :-) then we have to learn Mandarin :-)

  • write line with macro

    Locked
    1
    0 Votes
    1 Posts
    331 Views
    No one has replied
  • Opening a .dxl file from Notepad++

    Locked
    2
    0 Votes
    2 Posts
    1k Views
    EkopalypseE

    @Don-Fowler

    the debug-info from the ? menu would allow us to see how npp has been installed
    in order to provide a more detailed info what you can try to make this work again.
    Currently, I can only advise to rename config.xml and hoping you are taking the correct one.