• Help with Regex/Find/Macro

    Help wanted · · · – – – · · ·
    2
    0 Votes
    2 Posts
    123 Views
    CoisesC

    @João-Borloth said in Help with Regex/Find/Macro:

    Good morning!
    Everyone, I couldn’t understand REGEX.
    I believe there’s a REGEX solution (Find or Filter) to solve my problem.
    I need Notepad++ to search line by line and find the lines that contain:

    A word with all letters in uppercase (example: LTDA) A word with all letters in lowercase (example: and) A word with mixed lowercase and uppercase letters (except capitalized words) (for example, find: hoUse, HOuse, HousE)
    but NOT find House.

    This would require 3 Regex and/or 3 macros.
    Example sentences:
    My HouSe is Beautiful => Find “HouSe” and “is”
    My House Is Beautiful => Ok, Don’t find anything
    MY House IS Beautiful => Find “MY”, “IS”

    Thank you

    Your example doesn’t quite match your statement. If, as per your statement, you want to find lines which contain one or more words that do not consist of a capital letter optionally followed by one or more lower case letters, then try:

    (?-is)^(?!\u\l*+([^\w\r\n]+\u\l*+)*+[^\w\r\n]*$).*+

    You can find them one by one, or click Find All to get a list.

    If, as per your example, you want to find words that do not consist of a capital letter optionally followed by one or more lower case letters, try:

    (?-is)\b(\u\l*+)?+\w++

    I tried to cover likely cases involving punctuation, but test. I’m not promising it’s perfect. (Come to think of it, I’m sure these will not handle words with apostrophes correctly.)

  • 0 Votes
    5 Posts
    157 Views
    Mr-BrunesM

    @PeterJones that’s great. I wonder if it’s a Win11 ‘feature’ that prevents the graceful app close/shutdown.
    Either way I know now what the smoking gun looks like so will be mindful of that in future.
    Tx for the analysis and for filing the plugin issue.

  • 0 Votes
    10 Posts
    8k Views
    Serpens66S

    @xomx thank you very much :) hopefully the plugin gets updated some day, the auto-check is quite useful…

  • When maths is reinvented by CHATGPT

    Humour
    5
    6 Votes
    5 Posts
    2k Views
    Lycan ThropeL

    @donho ,
    And here I was, hopeful that making excuses about it being a computer error was over, with AI handling the responses. Even the AI has to make an excuse that it was (brain) computer error. :-)

  • 2 Votes
    2 Posts
    2k Views
    ThosRTannerT

    Updated linter++ to v1.0.1

    Most obvious changes:

    Works properly in 32 bit mode Ability to switch linting off and on - mainly for people with slow PCs Double clicking on an error in the ‘system’ tab will open a new notepad++ buffer and provide more detail on the error Ability to define your own variables to be used in commands.

    This is available at the same page as above.

  • 0 Votes
    14 Posts
    339 Views
    PeterJonesP

    @guy038 ,

    I think you missed my point.

    My point was not, “you can enter C0 using Ctrl+<key>, so there’s no need/benefit to be able to also enter C0 using Alt+0###”. My point is, all you have to do to be able to get Alt+0### access for C0 codes is to turn off the option named “prevent control character (C0 code) typing into document”: if you have things set up in a way that you want to be able to enter control codes, then you are the kind of user who probably doesn’t need the accidental-Ctrl+combo “protection” that enabling that option provides.

    Making the developers try to intercept the keystrokes before Windows turns the keystrokes from multiple presses into sending a single character to the app, just because you aren’t willing to turn off the anti-C0-“protection” seems the wrong way around. N++ already provides the option that allows you to enable typing C0 codes, whether by Ctrl+<unmapped> or by Alt+0### for C0 codes, so if you want to enter C0 codes, then set the option appropriately.

    solution cannot be applied because :

    Or, I would say, the “solution cannot be applied without unmapping pre-defined shortcuts, which is simple to do using Shortcut mapper”. (Or, I would say that, if that were a “solution” I were recommending; but it wasn’t.)

    Enabling vs disabling of features always come with tradeoffs, and power users of Notepad++ make those tradeoffs every day.

    Maybe I’ll put it this way: the option is literally named “prevent control character (C0 code) typing into document”. If you want to be able to type control characters (C0 codes) into the document, you obviously have to turn off that option. This seems highly reasonable to me.

  • 0 Votes
    2 Posts
    94 Views
    PeterJonesP

    @Dawg1104 said in Adding a Language to official Notepad++:

    Is it at all possible to add a language to Notepad++ officially?

    At all? Definitely.

    Practically? It depends on the language.

    Notepad++ uses a library called Lexilla for handling the syntax highlighting of “official” languages. Lexilla actually provides some languages that Notepad++ has not yet exposed to its users. I have actually done a couple PR where I submitted the Notepad++ code update to enable those “hidden languages”.

    But if it doesn’t already exist in Lexilla, then someone would have to write the lexer per Lexilla standards, then submit it to Lexilla. One, in theory, could just submit a request that Lexilla add the language, but unless it happens to be a language that one of the Lexilla team is interested in, there’s very little chance they will implement it – for example, awk was requested to be added to Lexilla in 2009, but since the developer isn’t interested in it, it’s never been implemented. So practically, to add a new language to Lexilla, you have to write it.

    Those are the two paths to being “officially” added. But there are more paths to unofficial:

    There might already be a UDL (User Defined Language) available in the UDL Collection, If so, anyone can easily download the UDL definition from there and install it into their copy of Notepad++ per the UDL Collection instructions or, if you already have a UDL defined, but there isn’t one for that language in the Collection, you can submit it to the collection as described in the Collection instructions if it’s a simple list of keywords and operators and maybe a folding symbol (like the { ... } of C-style languages), it’s pretty easy to make your own UDL (and then submit it to the collection) my CollectionInterface plugin makes it really easy to download and install a language from the UDL Collection. wink wink nudge nudge If the logic is more complicated than simple keyword matching, then it’s possible to write a lexer plugin (overview found in the User Manual) – and such a plugin can be submitted to the Plugins Admin. (One of the most famous lexer plugins is the GEDCOM lexer, but there are actually quite a few of the plugins that have lexing capability among their features.)

    So, what language are you looking for, that you cannot yet find?

  • Search & Replace

    Help wanted · · · – – – · · ·
    3
    0 Votes
    3 Posts
    96 Views
    guy038G

    Hello, @Jose-Ramalho, @peterjones and All,

    @jose-ramalho, let’s suppose this INPUT text :

    move $a swap $b, $c

    Then :

    Open the Replace dialog ( Ctrl + H )

    Uncheck all box options

    FIND (?-s)^(.+)\t(.+)

    REPLACE \1 FIXED_TEXT \(\2\)

    Select the Regular expression search mode

    Possibly, check the Wrap around option

    Click on the Replace All button

    => You should get the following OUTPUT text :

    move FIXED_TEXT ($a) swap FIXED_TEXT ($b, $c)

    This is just my first idea. Obviously, this requires some ajustements. See you later !

    Best regards,

    guy038

  • Notepad++ v8.8.4 Release

    Locked Announcements
    1
    3 Votes
    1 Posts
    2k Views
    No one has replied
  • 32x32 sources for small Standard icons

    General Discussion
    9
    0 Votes
    9 Posts
    3k Views
    deleeleeD

    @PeterJones Thanks! 🙂

  • 0 Votes
    5 Posts
    172 Views
    xomxX

    @Notepadder said in Strange Notepad++ file recovery:

    How can I access the files in this folder from a more recent restore point as with first crash?

    If there is also a more recent Windows OS Restore Point but you selected an older one somehow (with older N++ backup folder state) during your effort to revive your PC, you can try to extract newer N++ files by ShadowExplorer.

  • Notepad++ v8.8.4 Release Candidate

    Announcements
    31
    2 Votes
    31 Posts
    5k Views
    PeterJonesP

    @Ekopalypse said in Notepad++ v8.8.4 Release Candidate:

    Does that mean if you are using 8.8.2 you can’t use the plugin admin to install plugins without unlocking gup.exe first? Because I just checked again and I can.

    Weird. I had assumed that if the MotW existed on gup.exe, it wouldn’t run. But no, with v8.8.2 portable, if gup.exe has MotW, Plugins Admin will still install plugins; but on v8.8.3 portable and v8.8.4-RC2 portable, if gup.exe has MotW, Plugins Admin will not install plugins

  • 0 Votes
    3 Posts
    934 Views
    BoomBookB

    @PeterJones Thank you. As far as I can see, the function has not been removed. Before concluding this, I downloaded the versions one by one and checked the settings to see if it was still there. I was only able to find an option under “Default Directory.” My issue is now resolved. Thank you.

  • 0 Votes
    9 Posts
    220 Views
    Wally WilsonW

    @PeterJones

    Hi Everyone,

    I decided to drop back and punt. I cannot get hung up on this. I have other problems, and too much to do.

    I uninstalled the latest version, then downloaded the previous version (8.8.2), installed it, and installed DSpellCheck again. It is working. The underlining is not as prominent as I would like (even after adjusting the size to max), but it will have to do.

    I want to thank everyone who replied. Unfortunately, I do not have enough points to upvote anyone — sorry.

  • 0 Votes
    4 Posts
    94 Views
    PeterJonesP

    I thought someone had suggested combining it to a single dialog, but there was some deep technical reason it was infeasible

    I looked through old issues (opened and closed): the closest I could find was the Isse#12079, where the loading of the current session would prompt N times if there were N network files missing. There was quite a lot of back-and-forth (hundreds of comments), but eventually, they were able to make it work, and get a YesToAll/NoToAll message added to the dialog when multiple files from the session were not available.

    Since it was feasible in that situation, I am hoping it’s also feasible here. Thus, I created Issue #16908 to see if the “Keep non existing file” dialog (when the network goes down) and the “Reload” dialog (when the network comes back) can add the YesToAll/NoToAll buttons. I don’t know whether it’s really feasible, or if it will ever be implemented, but the request has at least been made. Those who want this feature can go to that issue and upvote and/or watch for whether or not it gets implemented.

  • Sorting text with numbers

    Help wanted · · · – – – · · ·
    4
    0 Votes
    4 Posts
    166 Views
    guy038G

    Hello, @michael-gomez, @coises, @thomas-knoefel and All,

    As @coises said, you could achieve your goal with the buit-in regular expression engine of Notpead++ !

    So, from your INPUT text :

    Warsongs rolls 206 Tykee rolls 206 Shadowhunter rolls 798 Ravencauthon rolls 229 Omgwtflolroflgg rolls 479 Nephlite rolls 576 Groverton rolls 943 Blodhgram rolls 829 Azria rolls 675 Antonioklaus rolls 720

    Using the following regex S/R :

    FIND (?-s)^.+?(\d+)

    REPLACE \1 $0!

    => You should get this temporary text :

    206 Warsongs rolls 206! 206 Tykee rolls 206! 798 Shadowhunter rolls 798! 229 Ravencauthon rolls 229! 479 Omgwtflolroflgg rolls 479! 576 Nephlite rolls 576! 943 Groverton rolls 943! 829 Blodhgram rolls 829! 675 Azria rolls 675! 720 Antonioklaus rolls 720!

    Then using the menu command :

    Edit > Line operations > Sort Lines Lexicographically Descending ( Should be better sorted than using the Sort Lines As Integers Descending ! )

    You would be left with that temporary text :

    943 Groverton rolls 943! 829 Blodhgram rolls 829! 798 Shadowhunter rolls 798! 720 Antonioklaus rolls 720! 675 Azria rolls 675! 576 Nephlite rolls 576! 479 Omgwtflolroflgg rolls 479! 229 Ravencauthon rolls 229! 206 Warsongs rolls 206! 206 Tykee rolls 206!

    And, finally, with the last regex S/R, below :

    FIND ^\d+\x20

    REPLACE Leave EMPTY

    Here is you expected OUTPUT text :

    Groverton rolls 943! Blodhgram rolls 829! Shadowhunter rolls 798! Antonioklaus rolls 720! Azria rolls 675! Nephlite rolls 576! Omgwtflolroflgg rolls 479! Ravencauthon rolls 229! Warsongs rolls 206! Tykee rolls 206!

    But, indeed, as @coises mentionned it, the two records with the same integer part 206 are inverted !

    Best Regards,

    guy038

  • 0 Votes
    6 Posts
    180 Views
    Daniel N 0D

    Thank you both!

  • 0 Votes
    5 Posts
    2k Views
    PeterJonesP

    @Mit-Jean ,

    Notepad++ has a plethora of ways to decide which file(s) should undergo search/replace. I am not convinced it needs another.

    One document: Search > Replace > Replace All = does replacement whether there’s a saved file or not All open documents: Search > Replace > Replace All in All Opened Documents = does replacement whether there’s a saved file or not Across multiple files: Search > Find in Files > Replace in Files = does replacements only in files saved to the filesystem Across a specific set of files in a “Project”: View > Project Panels > Project Panel N, then in the Project Panel, Right Click on the workspace > Find in Projects (or Search > Replace, pick the Find in Projects tab) and then run Replace in Projects

    My original thought was that, instead of somehow “marking” a file for “MOD scope”, you would just add your file to the project, and use Find in Projects. But since you want to include documents that haven’t been saved to a file yet, that won’t work (because Projects require that there’s an underlying file for everything added to the Project). However, I might give the advice that it would improve your workflow (and reduce the chances of losing data) if you were able to update your workflow to always save a file to the filesystem before doing any search/replace in it (especially as a multi-file S/R, as that’s a situation where you might not notice right away that your S/R didn’t work quite as expected, and you might move beyond the undo-history before you discover your mistake). (My personal opinion is that anyone who tries to do any more editing than Create File then Save, or maybe Create File then paste boilerplate then save, is just begging their computer to lose data for them: computers crash, and applications cannot perfectly/flawlessly prevent loss of data when they do; having unsaved data is foolish, IMO. For the ephemeral stuff, I have a “scratchpad” document always open, and I make liberal use of the AutoSave plugin, as described in this FAQ. My only exception to this rule is that I often create an empty unsaved tab to paste in data from a post in this Community, verify my suggestion works, and then delete it, all with it never being saved to disk; but that’s because I know that there is a 0% chance that I would care that the data were lost if my computer crashed while I was in the middle of it, because it’s data copy/pasted from the forum.) But enough of my preaching.

    If you were to make an official feature request – like @Alan-Kilborn hinted with his link – then I would say don’t word it as you currently do: Notepad++ already has a way to apply a specific color to a document’s tab (right click on the tab, Apply Color to Tab > Apply Color N), so instead of creating yet another way of marking the file for your “MOD scope”, what I would suggest is asking for “Replace in All Tabs of Color N” where “N” is 1…5 for the five possible colors; this would make the interface very similar to the Find in Projects dialog, where you can select one of the three project panels. That way, instead of having some new concept of “MOD scope”, it would be making use of a way that Notepad++ already provides to indicate similar tabs – it would actually give you five independent “MOD scopes” simultaneously, without introducting another new concept to the N++ interface.

  • 0 Votes
    2 Posts
    117 Views
    PeterJonesP

    @yeger-eren ,

    My answer is not “AI” specific.

    Maybe syntax highlighting tweaks,

    Notepad++ syntax highlighting is already pretty good; I’m not sure there is anything that needs to be “tweaked” in that regard when looking at code that you don’t create.

    auto-format tools,

    Notepad++ does not have built-in per-language code cleanup (“auto-format”, indentation fix, etc), because very few languages have One Right Way to format – and those that think they do actually have multiple factions who do things slightly differently, anyway. Notepad++ would never be able to get enough options to make everyone happy for all 90+ of the built-in programming languages that it has syntax highlighting for, let alone the uncountable number of possible UDLs that might exist.

    That said, there are plenty of language-specific plugins for Notepad++: if you’re generating XML, then XML Tools will help you format it; if you’re working with JSON, then JsonTools or JSON Viewer would be helpful; etc. And generically, @Michael-Vincent shares an example script for the NppExec plugin that is able to run an external “pretty print” utility for multiple languages depending on file extension in this post: his script does it for C, HTML, Perl, and Python, but it shows the pattern, so if you were getting code for another language, you could definitely call any external “pretty print” for whatever language you are using.

    Also, @Ekopalypse has the NppLspClient plugin, which will allow you to connect to an LSP Server for your language – and the tips page shows examples of how to configure it for various languages. Some LSP servers will respond to the Plugins > NppLspClient > Format Document or Format Selected Text commands by formatting according to the server’s settings – but not all do.

    regex replacements, or clever macros that make the process smoother?

    Every regex (or regex/editing macro) is specific to a very limited transformation; coming up with a generic one for something as indefinite as “fixes AI-generated code” is impossible. About the closest we come is our FAQ: Generic regex formulas, which lists a few different template regex, that you can use as a starting space for doing common tasks that we’ve seen requested year after year – though none of them are specific to “AI code craziness”.

  • Applying Diff patches?

    General Discussion
    5
    0 Votes
    5 Posts
    1k Views
    PeterJonesP

    @PeterJones said in Applying Diff patches?:

    I commented on that Issue to request that apply patch be considered alongside create patch.

    as mentioned here, as of ComparePlus v2.0.0, the plugin can generate and apply standard patch files; see also the release notes. Thanks to @pnedev for the update.

    (Until it makes it into the Plugins Admin, the new version can be manually installed from the zipfiles found on the v2.0.0 release page)