• 0 Votes
    5 Posts
    211 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
    63 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”.

  • [New Plugin] MultiReplace

    Notepad++ & Plugin Development
    74
    3 Votes
    74 Posts
    34k Views
    Mark OlsonM

    @Thomas-Knoefel
    Your idea of a plugin interface to determine if a tab is pinned seems very reasonable, so I created this GitHub issue to ask for such a feature.

  • Applying Diff patches?

    General Discussion
    5
    0 Votes
    5 Posts
    431 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)

  • Opening Files

    Help wanted · · · – – – · · ·
    3
    0 Votes
    3 Posts
    134 Views
    Alan KilbornA

    Here’s my script entry, which does exactly this:

    open additional ffiles to the left of the files that are already open?

    I call the script MoveJustOpenedTabToExtremeLeft.py and instructions for use appear in the comments in the source code.

    # -*- coding: utf-8 -*- from __future__ import print_function # Python2 vestige! ######################################### # # MoveJustOpenedTabToExtremeLeft (MJOTTEL) # ######################################### # note: # This script was developed and tested under Python3 64-bit on unicode (non-ANSI) encoded data. # It may work as-is using Python2 and/or ANSI-encoded data and/or 32-bits, but that would be incidental. # references: # https://community.notepad-plus-plus.org/topic/27054/opening-files # for newbie info on PythonScripts, see https://community.notepad-plus-plus.org/topic/23039/faq-desk-how-to-install-and-run-a-script-in-pythonscript #------------------------------------------------------------------------------- # ensure this file is not executed directly: assert __name__ != '__main__', 'Cannot run this script directly; for testing, could execute this at console >>> prompt: from MoveJustOpenedTabToExtremeLeft import MOVE_JUST_OPENED_TAB_TO_EXTREME_LEFT' # to execute, use this in (e.g.) user startup.py: # from MoveJustOpenedTabToExtremeLeft import MOVE_JUST_OPENED_TAB_TO_EXTREME_LEFT # another execution option would be to copy and then paste that line into the PythonScript console >>> box # note: if running via startup.py, need to make sure that "Initialisation" for "Python Script Configuration" is set to "ATSTARTUP" and not "LAZY". #------------------------------------------------------------------------------- from Npp import * import threading #------------------------------------------------------------------------------- class MJOTTEL(object): def __init__(self): notepad.callback(self.fileopened_callback, [NOTIFICATION.FILEOPENED]) def fileopened_callback(self, args): #print('FILEOPENED:', args) IDM_VIEW_GOTO_START = 10005 threading.Timer(0.05, lambda : notepad.menuCommand(IDM_VIEW_GOTO_START)).start() #------------------------------------------------------------------------------- MOVE_JUST_OPENED_TAB_TO_EXTREME_LEFT = MJOTTEL()

    Notes:

    the script is rather simple-minded: it works for the simple case of opening 1 file at a time. If you attempt to open 2+ at the same time (e.g. drag and drop 2+ files from Explorer into Notepad++, use File > Open and specify 2+ files, etc.), the script causes only 1 of the files to move. If this is a big limitation for functionality, I could look into how to successfully achieve it.

    the threading stuff seems like it wouldn’t be necessary, but it is. Probably what happens (I didn’t verify) is that the file-opened notification message comes before Notepad++ is entirely done with everything it does to open a file. Delaying (via the threading call) moving the tab allows control to return to Notepad++ to let it finish doing its thing, before the script moves the tab.

  • 0 Votes
    3 Posts
    84 Views
    Terry RT

    @Tall-Navy-Guy said in Backup Files for New, Unsaved Tabs Are Deleted When Tab Is Closed — Bug?:

    Actual Result
    The backup created for the unsaved tab is immediately deleted when the tab is closed — there is no way to recover the text.

    Why This Matters
    Users (myself included) rely on the periodic-backup feature as a safety net for unsaved work. Accidentally closing an unsaved tab—or closing all tabs—should not silently discard those backups; other editors retain them until the user explicitly deletes the file or disables backups.

    You really need to understand what the backup is designed to do. There is a FAQ section and in there is this post which explains in detail what it does.

    You say you rely on this process “as a safety net” yet what you really seem to say is that this will be the “one and only” copy of the data you create. I am actually concerned to learn that you are relying on some process which clearly you misunderstand for saving what seems to be critical data.

    I believe you should get a message when closing the new 1 tab (not the whole application) asking if you want to keep it (see image in @Lycan-Thrope post), so in reality the application does NOT silently discard the backup, it asks you, it seems you confirm you don’t want the data since you are asking this question. The only “silent” process will be if you close Notepad++ without first closing any tabs. When you start Notepad++ later, all tabs should remain with their content intact.

    For your idea to work you would continue to rack up endless “backup” files, all with the same starting name new 1... and have very little idea which file contains which data you want.

    If you were to search this forum you will find it littered with unhappy users who like you misunderstood the process, relied on it for their only copy, only to find that inevitably the process eventually failed them, often due to external factors outside of Notepad++'s control.

    Please read the FAQ post and I strongly suggest changing the way you use Notepad++.

    Terry

  • 0 Votes
    2 Posts
    55 Views
    PeterJonesP

    @vasstr said in subnets, search/find and regular expression, txt2xml:

    search/find and regular expression?

    Yep.

    FIND WHAT = ^(\d+\.\d+\.\d+\.\d+)/(\d+\.\d+\.\d+\.\d+)
    REPLACE WITH = <IPHost transactionid="">\r\n <Name>n$1</Name>\r\n <Description>subnet</Description>\r\n <IPFamily>IPv4</IPFamily>\r\n <HostType>Network</HostType>\r\n <IPAddress>$1</IPAddress>\r\n <Subnet>$2</Subnet>\r\n</IPHost>
    SEARCH MODE = Regular Expression
    REPLACE ALL

    Notes:

    ^ makes sure the match must start at the beginning of a line each \d+\.\d+\.\d+\.\d+ match four dot-separated integers The parens around those put them in two groups The $1 and $2 in the replacement refer to the values of group1 and group2, respectively the \r\n in the replacement are the standard windows CRLF end-of-line sequence, so that your replacement can go over multiple lines.

    ----

    Useful References Please Read Before Posting Template for Search/Replace Questions Formatting Forum Posts Notepad++ Online User Manual: Searching/Regex FAQ: Where to find other regular expressions (regex) documentation
  • 0 Votes
    4 Posts
    180 Views
    I HayI

    @guy038 @Coises

    Thank you both of you, you’ve both given me more to learn which is great. I had wondered after posting about getting rid of the newlines and replacing them with an unused character (though I might have hit some line limits with that somewhere), but I’m pleased to find it can be done without that. I didn’t know about the reverse lines option and would never have thought of using it for regexp purposes - good to know! - if the world is too hard as it is, turn it upside down lol.
    Thanks again both of you :-)

  • 0 Votes
    5 Posts
    161 Views
    PeterJonesP

    @Coises said in I go to Style Configurator set a new font size Using Global Styles, save and nothing happens:

    if someone set a value in Global Override before it was moved … They’re still changing the first entry in the list.

    If they did, and it moved for them, they would have had to delete stylers.xml and let a new one be generated in the new order (or manually re-ordered), because stylers.xml doesn’t get overwritten to the new order when you upgrade from a version before the re-order to a version after the re-order. (Hence, my Config Updater plugin, to apply those kinds of fixes.)

    So, except in the unlikely event that they deleted their stylers.xml and let it be re-generated, then all that remains is that either it was in the old order and probably still is in the old order (but their understanding has improved, and they are now correctly looking at the Default Style), or it was in the new order and had all the modern warnings in the GUI and they still checkmarked the override. I find the still-in-old-order the most likely scenario, but that’s just my estimate. (Thus, I disagree with your conclusion that “They’re still changing the first entry in the list”, as it seems unlikely to me that they deleted/regenerated stylers.xml, because that doesn’t seem a natural behavior of any normal user, to me.)

    My point in linking to the manual is that it’s all explained in there, and explains how to fix the stylers.xml to move Global Override to the end, even if it’s not at the end, so that you never accidentally use the Global Override.

  • Installation Bug?

    Help wanted · · · – – – · · ·
    5
    1 Votes
    5 Posts
    216 Views
    mpheathM

    @xomx

    Thanks for the confirmation. Issue has been posted at Github #16896 .

  • Notepad ++ Plugin Geneator

    Help wanted · · · – – – · · ·
    3
    0 Votes
    3 Posts
    89 Views
    Mark OlsonM

    @ISSUE-BADGE

    If your plugin concept is very simple, you might find it easier to write a PythonScript script rather than writing a full-blown plugin.

    If you need to write a full plugin and you’re used to working with garbage-collected languages like Python/Java/JavaScript, I’d recommend starting with NppCSharpPluginPack, which is a C# plugin template that I actively maintain.

  • 0 Votes
    3 Posts
    129 Views
    CoisesC

    @BrenMar

    Please try downloading a portable version:

    https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v8.8.3/npp.8.8.3.portable.x64.zip

    Unzip that to a folder. Then open the folder and double-click the notepad++.exe file. That should open Notepad++. Try opening a file from File | Open. Then try opening a .txt file in regular Notepad and be sure that works.

    If all that works, then we know what’s going wrong has something to do with the installer (edit to add: or corrupted user settings), not the program proper. That doesn’t (yet) solve your problem, but it will help figure out where to look next.

    If you can’t run the portable version, or you can run the portable version but you can’t open a file, then that’s a different kind of problem.

    Please report back and be as detailed as you can about what you did and what happened.

  • 0 Votes
    3 Posts
    78 Views
    CoisesC

    @DanielTheGreatAu said in Drag-and-drop not working in editor:

    a hidden setting somewhere that reverts Notepad++ to ‘normal’ Windows behaviour

    Settings | Preferences… | Editing 2 | Multi-Editing: uncheck Enable Multi-Editing to restore normal Ctrl+drag behavior.

    Shift key down, then drag on a selection, as far as I know, has never moved the selection in Notepad++ — it just changes the selection. You don’t need the Shift key to move a selection.

  • 0 Votes
    2 Posts
    83 Views
    PeterJonesP

    @taigama_coder said in UDL highlight words between 2 keyword:

    How can I use UDL to fromat it?

    That is beyond the capability of UDL: it’s designed for simple keyword and operator highlighting, and what you are asking would require a custom lexer…

    Normally, I would suggest the EnhanceAnyLexer plugin, which allows adding foreground coloring based on regular expressions… but since you are asking to highlight the whitespace, and whitespace by definition is not using the foreground color, I don’t think it’s features would help you.

  • 0 Votes
    11 Posts
    541 Views
    guy038G

    Hello, @peterjones,

    My bad ! Thanks to the @dinkumoil’s post, I realized that you already fully documented the npp-compatible-versions and old-versions-compatibility attributes in the official N++ documentation ! So, most of the initial posts about this topic seem useless :-((

    Anyway, this was the occasion to revisit these important notions. As an example, if we consider the true maximum syntax, each made of 3 elements, which is :

    - "version": "a.b.c", - "npp-compatible-versions": [d.e.f,g.h.i], - "old-versions-compatibility": [j.k.l,m.n.o][p.q.r,s.t.u],

    My understanding supposes that this means :

    Latest plugin version a.b.c of the plugin works with all releases of Notepad++ between d.e.f and g.h.i, included.

    Older plugin versions between j.k.l and m.n.o, included, should work with all N++ versions between p.q.r and s.t.u , included.

    The plugin version a.b.c is more recent than, both, the versions j.k.l and m.n.o of that plugin.

    This example likely represents the case of a plugin no longer maintained after the N++ release g.h.i.

    As always, RTFM ;-))

    Best Regards,

    guy038

  • 0 Votes
    2 Posts
    60 Views
    mathlete2M

    @Arne-Everhard it sounds like you’re referring to the functionality of the Move Tab Forward and Move Tab Backward options in the View > Tab menu. If so, both have default shortcuts, but they can be modified in the Main Menu tab of the shortcut mapper.

    Note: I actually had a difficult time finding those particular options in my own window at first; you may need to filter by “tab” to see these particular options right away.

  • 0 Votes
    9 Posts
    2k Views
    PeterJonesP

    After this conversation, I worked briefly on a workaround. I took the 16x16 standard-icon BMP files from the N++ source code, converted them to ICO format, then on all the files, I used an image program to upscale from 16x16 to 32x32, and make .ico files that have both 16x16 and 32x32 resolution files. The 32x32 are admittedly ugly (because they are just enlarged versions of the 16x16), but it’s at least a starting place, and will give the ability to have icons that are based on the standard icon set, but being able to use them in large-icon mode.

    Assuming a standard installation of Notepad++ (using %AppData% config directory), to use these dual-resolution ICO files:

    Go to %AppData%\Notepad++\ in Windows Explorer Create a directory toolbarIcons and a subdirectory toolbarIcons\StandardDualResolution Download the .ico files in https://github.com/pryrt/nppStuff/tree/main/StandardIconUpscaling/GIMP DualResolution 32x32 16x16 and unzip into toolbarIcons\StandardDualResolution\ update: added zipfile for easy download Rename toolbarButtonsConf_example.xml to toolbarButtonsConf.xml Edit that file, and near the end, change the line from <ToolBarIcons icoFolderName="" /> to <ToolBarIcons icoFolderName="StandardDualResolution" /> Save the toolbarButtonsConf.xml exit Notepad++

    The next time you run Notepad++, it should be using the custom versions of the standard icons. If you select Settings > Preferences > Toolbar and choose one of the “large” choices, it should use the custom icons in large (32x32).

    5ef248da-6716-4e80-a474-4147eb20d515-image.png

    This is obviously not ideal. But since there hasn’t been any official or publically-available 32x32 “originals” of those icons in 14+ years, that I can find, it’s the best thing I can think of for now. Someone with more image editing skill – or more AI skill – might be able to generate better 32x32 versions from the original 16x16 BMP files in the source code and create better-looking versions as ICO files. But until such happens, this might be a usable workaround.

  • Notetab++ novice questions

    Help wanted · · · – – – · · ·
    3
    0 Votes
    3 Posts
    337 Views
    PeterJonesP

    A few months ago, I said,

    I don’t know of anyone who has done that and made them public.

    After this conversation, I worked briefly on a workaround. I took the 16x16 standard-icon BMP files from the N++ source code, converted them to ICO format, then on all the files, I used an image program to upscale from 16x16 to 32x32, and make .ico files that have both 16x16 and 32x32 resolution files. The 32x32 are admittedly ugly (because they are just enlarged versions of the 16x16), but it’s at least a starting place, and will give the ability to have icons that are based on the standard icon set, but being able to use them in large-icon mode.

    Assuming a standard installation of Notepad++ (using %AppData% config directory), to use these dual-resolution ICO files:

    Go to %AppData%\Notepad++\ in Windows Explorer Create a directory toolbarIcons and a subdirectory toolbarIcons\StandardDualResolution Download the .ico files in https://github.com/pryrt/nppStuff/tree/main/StandardIconUpscaling/GIMP DualResolution 32x32 16x16 and unzip into toolbarIcons\StandardDualResolution\ update: added zipfile for easy download Rename toolbarButtonsConf_example.xml to toolbarButtonsConf.xml Edit that file, and near the end, change the line from <ToolBarIcons icoFolderName="" /> to <ToolBarIcons icoFolderName="StandardDualResolution" /> Save the toolbarButtonsConf.xml exit Notepad++

    The next time you run Notepad++, it should be using the custom versions of the standard icons. If you select Settings > Preferences > Toolbar and choose one of the “large” choices, it should use the custom icons in large (32x32).

    5ef248da-6716-4e80-a474-4147eb20d515-image.png

    This is obviously not ideal. But since there hasn’t been any official or publically-available 32x32 “originals” of those icons in 14+ years, that I can find, it’s the best thing I can think of for now. Someone with more image editing skill – or more AI skill – might be able to generate better 32x32 versions from the original 16x16 BMP files in the source code and create better-looking versions as ICO files. But until such happens, this might be a usable workaround.

  • 0 Votes
    2 Posts
    84 Views
    Mark OlsonM

    @PATRICK-MULOT

    This is probably a job for regular expressions, but it depends to some extent on the specifics of your task.

    If you have a text file where every line is a word that you need to search for, you need to do a scripting solution. This kind of question has been asked many times before on the forum and I’m too lazy to look up which posts it was answered in, but a PythonScript script that would accomplish this would probably be as follows:

    Open the file with the words you’re searching for (hereafter WORD_FILE) Open the PythonScript console Paste in the command words = [x + ' ' for x in editor.getText().splitlines()] then hit Enter. Open the file that you want to search in (hereafter TARGET_FILE) Paste in the command lines = [line for line in editor.getText().splitlines() if any(line.startswith(word) for word in words)] then hit Enter Open a new file. Paste in the command editor.setText('\r\n'.join(lines)) and hit Enter Your new file will contain only the lines in TARGET_FILE that started with one of the words in WORD_FILE followed by a literal space character

    If you want to find lines that start with "fam " or "blah " (as in “fam” or “blah” followed by a literal space character), you can do that by:

    Use Search->Find... from the Notepad++ main menu (Ctrl+F with default keybindings) to open the Find form. Set Search Mode to Regular expression. Set Find what: to (?-i)^(?:fam|blah)\x20.* This regular expression has these basic parts: (?-i), ^, (?:fam|blah), \x20, and .* The (?-i) says that this is a case-sensitive search (so it would exclude lines starting with FAM for example) The ^ means that we only search at the start of a line The (?:fam|blah) matches fam or blah The \x20 is a different representation of a normal space character, which I sometimes use in regular expressions to make it more readable The .* matches the rest of the line (. is any non-newline character and * means match 0 or more of the preceding pattern) Hit the Find All in Current Document button. A form will pop up at the bottom of the Notepad++ window showing all the lines that matched.
  • 0 Votes
    5 Posts
    167 Views
    Robert Or Janet DiebelR

    @guy038 Thanx much for your help