• New ILexer interface from PythonScript

    10
    2 Votes
    10 Posts
    963 Views
    Michael VincentM

    @rdipardo said in New ILexer interface from PythonScript:

    before the Python host is even ready to execute scripts.

    @Bas-de-Reuver

    Both are correct. However, PythonScript offers enough in the form of API and callbacks that we can access the compiled lexers and by reading in a config file (langs.hidden.xml) and stylers file (stylers.hidden.xml) based on their “.model.xml” versions, we can get pretty decent lexing for “non-standard” languages, including (ones I’ve tried):

    Stata Julia X12 Edifact BibTeX F# Raku

    Thanks to @PeterJones for his code pointer above in this thread which I highly modified to get to this solution.

    PS: If you include the GlobalStyles tag in the “hidden” stylers file, you can actually select it in the Style Configurator and make changes. The changes are not effective immediately, you need to save and then use PythonScript to .reload_lexer(), but the slight inconvenience of 2-step process for the few times I’ll do this … no big deal.

    ab0c1ac8-b248-46fb-9b08-336c6e9b194b-image.png

    Thank you all!

    Cheers.

  • How to have colored and numbered blocks?

    2
    0 Votes
    2 Posts
    259 Views
    PeterJonesP

    @Diego-Giurgola ,

    The colored blocks shown there are the “Change History” feature, which requires v8.4.6 or newer. So those line colors in the margin will change based on which lines have been changed or saved since you started editing the file.

    They are not an “attribute” that you can set, so you cannot say, “in file1.txt, I want lines 1-7 to have a green margin and 8-12 to have an orange margin”, so the feature that you are seeing will not do what I think you want.

  • UDL for .BAT or .CMD files

    2
    0 Votes
    2 Posts
    219 Views
    EkopalypseE

    @Christophe-MERCEY

    Probably not, since there is a built-in lexer.

    language menu:

    0e8bb8bf-0a5c-4dbe-8e6d-fcb0a9f07bb4-image.png

  • Default Find button

    3
    0 Votes
    3 Posts
    385 Views
    Alan KilbornA

    @Amazon-Books said in Default Find button:

    How can I make this “Find All in Current Document” button the default ‘Find’ button instead of “Find Next”?

    You can’t, at least not easily.
    I suppose what you want is to simply press Enter to have FACD happen.
    Suggest take @Lycan-Thrope 's suggestion and retrain yourself to hit Alt+d instead of Enter in this circumstance.

  • How to remember last opened position in Notepad++?

    2
    0 Votes
    2 Posts
    511 Views
    Alan KilbornA

    @dspjm

    That type of information is not remembered with the file (because the file is purely data, not metadata from use with a text editor). If you leave the file open, however, the N++ session file does remember this between runs of N++, and is what retains the caret position from run to run.

    The short answer to your question is “no”; the longer answer is that Notepad++ has scripting capabilities that could allow a script to be written to meet your desire.

  • UDL Number Suffix 2 not working when character also in Extras 2

    10
    1 Votes
    10 Posts
    1k Views
    Maggi 9295M

    @Ekopalypse said in UDL Number Suffix 2 not working when character also in Extras 2:

    @Maggi-9295 said in UDL Number Suffix 2 not working when character also in Extras 2:

    Just out of curiousity, is there some kind of documentation on this?

    I like the idea of having the configuration file and the help system in one place, and I hope the explanation is understandable. If this is not the case, let me know how I can improve it.

    I think it’s alright, no worries! I just wasn’t aware it uses the Notepad++ regex syntax and was searching which syntax it uses in the first place, but that’s just me not reading properly :P
    The Notepad++ documentation on searching is already more than comprehensive enough, so I think that should cover pretty much everything (once you got used to it, that is :P)

  • Shift Left, No Tabs

    15
    0 Votes
    15 Posts
    2k Views
    guy038G

    Hi, @alan-kilborn,

    Yes…, you’re right about it, Alan ! But how to get a simple behaviour ? Note that the macro is about deleting the first character, regardless its type !

    And, anyway, in your post https://community.notepad-plus-plus.org/post/83341, where you proposed the right regex method to delete the first 6 chars, they could be tabulation chars, as well ?

    BR

    guy038

  • 0 Votes
    2 Posts
    189 Views
    PeterJonesP

    @Random-Encounter ,

    UDL is not all-powerful: it focuses on defining a list of keywords, rather than arbitrary pattern matches, for syntax highlighting, so it cannot do what you want.

    However, the EnhanceAnyLexer plugin can apply the power of regex to change the foreground color of certain text; so you could install that plugin, define most of your language with the UDL interface; then, to get things to the left of an = to be a different color, use Plugins > EnhanceAnyLexer > Enhance Current Language, which will add or edit a section in its config file for your current language: the section will start with [NameOfUDLhere], and then consist of “color = regex” pairs (if the colors are in hex, it’s 0xBBGGRR for the blue, green, and red portions), along with a config line for “excluded_styles = …” which you probably don’t need to worry about)

    For my example, since I’m just using the dummy “Default Langauge” (which internally is labled as udf), I can use the following config section to get it to highlight text on the left of the = with brownish-orange:

    [udf] 0x66ad1 = ^.*(?=\=)

    42434862-d71d-4824-920a-b839722f7d37-image.png

  • Keys not being reognized

    2
    0 Votes
    2 Posts
    385 Views
    PeterJonesP

    @Larry-Schwartz ,

    There is nothing inherent in Notepad++ v8.4.7 or v8.4.8 that would reject those keys. My guess is that either you have something (AutoHotKey, or a rogue program, or malware or worse) that is intercepting those keys (maybe only sometimes, since they seem to work for MS products), or something was corrupted in your %AppData%\Notepad++\shortcuts.xml, which is where keyboard shortcuts are defined.

    To check the latter, the first step could be Settings > Shortcut Mapper > Scintilla Commands, then filter for HOME or END or the other keystrokes you mentioned, and see if they are still assigned to anything (or if they show up with a reddish background, which would indicate that some other command is also assigned to that keystroke, which could cause unexpected behavior)

    Alternately, you could exit Notepad++, delete/rename %AppData%\Notepad++\shortcuts.xml, and then restart Notepad++: it will recreate the shortcuts.xml file with default values, and it should go back to working normally. If not, then it’s most likely that some external application has hijacked those keys in a weird manner.

  • Quick way to mark columns using the keyboard

    3
    0 Votes
    3 Posts
    415 Views
    Joe BerryJ

    @Alan-Kilborn - This has the parts I was missing. Just tried it, now to develop a shortcut or macro! Thanks for your time and expertise.

  • Want REGEX to Check Every Line Indivdually

    6
    1 Votes
    6 Posts
    431 Views
    Alan KilbornA

    @kc270000 said in Want REGEX to Check Every Line Indivdually:

    Meant “at” typed ampersand. Thankfully Alan understood…

    Actually I think I glossed over ampersand and my eyes flew right to the non-working regex you provided – and I went from there quickly to the solution.
    :-)

    BTW, (maybe) the reason the OP’s regex cleared the entire document is that the regex didn’t contain anything to limit the match to each line. Typically this is done with (?-s) in combination with .* or .+ later in the expression. Without a ., and without any line-ending characters in the regex, it will match across lines and perhaps even consume the entire doc.

  • 0 Votes
    53 Posts
    6k Views
    PeterJonesP

    This discussion has stopped being about “new window” or about “shortcut keys”, and really ceased even being about Notepad++. And now it’s even attracting random posts as well.

    This topic is being locked. If anyone has Noteapd++ related discussion, a new topic can be started quite easily; if you need to, provide a link back to this discussion for reference.

  • macro to find/replace in current directory?

    4
    1 Votes
    4 Posts
    452 Views
    Alan KilbornA

    @rorso

    Cool that that technique can work for you. I had another idea which as “heavier” as it involved using a scripting plugin, so if that wouldn’t work out for you, I’d’ve gone down that road.

  • 0 Votes
    4 Posts
    309 Views
    tseGITT

    thx to all, that works fine for me

  • Extract specific data from log files?

    10
    0 Votes
    10 Posts
    1k Views
    guy038G

    Hello, @zorba-greek, @michael-vincent, @terry-r and All,

    A one way solution would be to use the following regex S/R :

    SEARCH (?xs-i) ^ .+? Fleet \x20 No , ( \d+ ) , .+? tag= ( \d+) .+? $ | ^ .+

    REPLACE (?1Fleet No \: $1 tag \: $2:)

    This regex :

    Searches for two consecutive lines, without the ending line-break, containing the string Fleet No, with this exact case, in the first line and the string tag=, with this exact case, in the second one and replace these two lines with the string Fleet No : $1 tag : $2, where $1 and $2 are the numbers located after Fleet No and tag=

    When no more line contains the string Fleet No, it graps all the remaining text till the very end of the file and deletes it

    So for instance, I will try to describe the process with this dummy example below :

    FIRST alternative : (?xs-i) ^ .+? Fleet \x20 No , ( \d+ ) , .+? tag= ( \d+) .+? $ [22-12-20 21:18:44.345] FROM LIVE <02:PAYDONE=0000022852>CRLF <---------------------------------------------------------------- ^ .+? [22-12-20 21:19:16.399] FROM LIVE <03:PAYDONE=0000022853>CRLF ----------------------------------------------------------------- .+? [22-12-20 21:21:54.286] FROM LIVE <$011B4B50:FleetCard_10:1,51.75,1,1,200001,Fleet No,5418,34322,TARJETA,,51.75,,3,0,1>CRLF -------------------------------------------------------------------------------->Fleet No,<--><-------------------------------- .+? Fleet No, \d+ .+? Fleet No, $1 [22-12-20 21:21:54.301] auth accepted tag=9812120450668854 device=V2CRLF --------------------------------------->tag=<--------------><--------> ( line-break NOT included in the regex ) .+? tag= ( \d+ ) .+? $ tag= $2 SECOND alternative : ^ .+ [22-12-20 21:25:11.284] FROM LIVE <02:PAYDONE=0000022854>CRLF ----------------------------------------------------------------- ^ .+ [22-12-20 21:25:20.141] FROM LIVE <04:PAYDONE=0000022855>CRLF ----------------------------------------------------------------- ( End of file ) .+

    Now, given the exact INPUT text, provided by @zorba-greek :

    [22-12-20 21:16:04.521] FROM LIVE <$011B4B50:FleetCard_10:1,51.75,1,1,200001,Fleet No,5411,34319,TARJETA,,51.75,,3,0,1> [22-12-20 21:16:04.553] auth accepted tag=9812120450668474 device=V2 [22-12-20 21:16:40.185] FROM LIVE <02:PAYDONE=0000022851> [22-12-20 21:17:20.677] TO LIVE <$011B4910:FleetCard_1:9812120450669349> [22-12-20 21:17:21.270] FROM LIVE <$011B4910:FleetCard_10:1,49.48,1,1,200001,Fleet No,5237,34320,TARJETA,,49.48,,2,0,1> [22-12-20 21:17:21.333] auth accepted tag=9812120450669349 device=V1 [22-12-20 21:18:44.345] FROM LIVE <02:PAYDONE=0000022852> [22-12-20 21:19:16.399] FROM LIVE <03:PAYDONE=0000022853> [22-12-20 21:20:18.292] TO LIVE <$011B5150:FleetCard_1:9812120450669482> [22-12-20 21:20:19.073] FROM LIVE <$011B5150:FleetCard_10:1,51.75,1,1,200001,Fleet No,2001,34321,TARJETA,,51.75,,3,0,1> [22-12-20 21:20:19.167] auth accepted tag=9812120450669482 device=V1 [22-12-20 21:21:53.536] TO LIVE <$011B4B50:FleetCard_1:9812120450668854> [22-12-20 21:21:54.286] FROM LIVE <$011B4B50:FleetCard_10:1,51.75,1,1,200001,Fleet No,5418,34322,TARJETA,,51.75,,3,0,1> [22-12-20 21:21:54.301] auth accepted tag=9812120450668854 device=V2 [22-12-20 21:25:11.284] FROM LIVE <02:PAYDONE=0000022854> [22-12-20 21:25:20.141] FROM LIVE <04:PAYDONE=0000022855>

    We get the expected OUTPUT text :

    Fleet No : 5411 tag : 9812120450668474 Fleet No : 5237 tag : 9812120450669349 Fleet No : 2001 tag : 9812120450669482 Fleet No : 5418 tag : 9812120450668854

    Notes :

    In the search regex, I use the free-spacing mode, (?x), for an easy reading of the different parts of this regex

    You probably noticed that all ranges of text, in my regex, need to be non-greedy ranges ( Syntax = .+? ), as each range must not contain, itself, the strings Fleet No and tag= nor the final line break !

    As this regex does not include the final line-break, it will keep them, as is, in the OUTPUT text

    The replacement regex (?1Fleet No \: $1 tag \: $2:) means :

    IF a Fleet number is found ( (?1... ) it rewrites the string Fleet No : followed with the Fleet number ( $1 ), the string tag = and the tag number $2, all separated with space chars and colon chars when needed

    ELSE it replaces with everything between the last : character, after $2 and the end of the conditional replacement ) i.e. nothing so it deletes all the remaining text till the very end of current file !

    Remark that the two first : chars, in replacement, are literal characters and must be escaped, in order to be rewritten as is when the group 1 is present

    Best Regards,

    guy038

  • is there a way to move files up and down inside a list of opened files

    8
    0 Votes
    8 Posts
    2k Views
    ImbalanceI

    @mkupper Thanks, I was just looking a way to move items up and down in the “Document list” pane, and that’s exactly the way (Ctrl-Shift-PageUp and Ctrl-Shift-PageDown). Awesome.

  • Can I tell np++ the encoding via pseudo comment?

    10
    0 Votes
    10 Posts
    806 Views
    Alan KilbornA

    Just to circle back (finally) on this; I ended up NOT pursuing a scripted solution to this because I didn’t hear anything back from the OP, and I don’t have great interest in this for my own use. Just FYI.

  • Find/replace across 100's of servers using automated script

    7
    0 Votes
    7 Posts
    358 Views
    Michael VincentM

    @Steve-Mueller

    So you need a local scripting / templating solution that allows you to specify the INI file template and variables and then have a “database” of variable to value mappings for each server. Run a script to create the configs, Ansible to deploy.

    There are several templating frameworks out there (Jinja2 and Mako come to mind for Python).

    I’m still failing to see how any of this is related to Notepad++ other than using Notepad++ to edit the files / templates and write your scripts.

    Cheers.

  • Find and delete <p></p>line in HTML

    6
    0 Votes
    6 Posts
    688 Views
    Alan KilbornA

    @jackdeland said in Find and delete <p></p>line in HTML:

    Do you really want approx. 60 permutations and slapdash tries at everything? I am working 4 deadlines currently and don’t have anymore time to learn all I need. I have only twice asked for help in a forum with others far beyond my tech proficiency in one area, and I see I am dealing with some very insecure people. SO glad I am not in your world.

    Wow. Seriously.

    Since the answer was provided before that rant was typed, paraphrasing it, I think it reads “Thank you Peter Jones for the kindly help”.

  • Search In Files does not work for PDF

    3
    0 Votes
    3 Posts
    1k Views
    PeterJonesP

    @SAMEER-NAVARE ,

    See the FAQ for more on what Alan mentioned.