• Opening Files

    Help wanted · · · – – – · · ·
    3
    0 Votes
    3 Posts
    196 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
    137 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
    133 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
    242 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
    210 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
    319 Views
    mpheathM

    @xomx

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

  • Notepad ++ Plugin Geneator

    Help wanted · · · – – – · · ·
    3
    0 Votes
    3 Posts
    128 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
    116 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
    112 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
    2k 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
    82 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
    398 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
    128 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
    207 Views
    Robert Or Janet DiebelR

    @guy038 Thanx much for your help

  • Translation/Localization parameter during silent install

    Translation
    2
    3 Votes
    2 Posts
    3k Views
  • 0 Votes
    12 Posts
    600 Views
    Mark OlsonM

    @rdipardo

    But what if the given document is not UTF8, but ANSI or UTF-16?

    I’ve finally gotten around to implementing a fix for this issue in JsonTools. I did this first in JsonTools because it has a lot of features that read the text of the file. It appears to work fine for ANSI files (you can test it on this example file I added).

    As I noted in the commit message, there are some features that are broken because my JSON parser’s code for determining node position assumes that the document is UTF8-encoded.

    …or UTF-16?

    JsonTools has always worked correctly on files with any encoding except ANSI, so at least on my machine, I have just confirmed that Notepad++ internally represents documents as UTF-8 if the file itself is in UTF-16 or some exotic encoding like OEM 865.

  • Color of hits for find and replace

    General Discussion
    4
    0 Votes
    4 Posts
    680 Views
    C

    @Coises Thanks, it was the smart highlighting. Problem solved.

  • 0 Votes
    3 Posts
    609 Views
    Alan KilbornA

    To expand on the explanation, for a small number of lines, put the caret in column 1 of line 1. Press Shift+Alt+DownArrow multiple times, enough so that a “skinny but tall caret” appears before the column 1 data in all lines, to wit:

    25400676-feb5-4a56-86ab-a9413176e83c-image.png

    Then press Space two times, to obtain:

    f0784327-74d1-4788-8da2-7c1acf2b63f7-image.png

  • JsonTools v5.5. is live!

    Notepad++ & Plugin Development
    22
    7 Votes
    22 Posts
    14k Views
    Mark OlsonM

    @User-Name said in JsonTools v5.5. is live!:

    And then if I open any file, it opens formatted.

    Glad to hear it!

    But the first opened file is not formatted :)

    That’s probably just a limitation of how PythonScript is implemented, and I don’t think there’s anything I can do about that.