• .TXT filenames don't get passed to NotePad++

    5
    1 Votes
    5 Posts
    312 Views
    afk afkA

    OK!! (maybe)

    You were right. I found the registry entry
    \HKEY_LOCAL_MACHINE\SOFTWARE\Classes\txtfile\shell\open\command
    with the entry
    //“c:\Program Files\NotePad++\NotePad++.exe”
    and added “%1” and it worked first time, every time.
    Thanks very much.
    I tried to upvote your answer but I don’t have enough “reputations”
    Austin Kelly

  • How to highlight using plugin

    2
    0 Votes
    2 Posts
    252 Views
    PeterJonesP

    @Eileen-Ling said in How to highlight using plugin:

    highlight a certain word in red color using enhanceanylexer.

    If by “highlight” you mean “change the background to red” – no, EnhanceAnyLexer only changes foreground.

    If by “highlight”, you mean “change the foreground text color to red”, then yes.

    [LexerOrUdlNameHere] 0x0000FF = hello
  • User Defined Language

    2
    0 Votes
    2 Posts
    211 Views
    PeterJonesP

    @Eileen-Ling ,

    With just the User Defined Language (UDL) syntax, what you want is probably not achievable.

    However, if you install the EnhanceAnyLexer plugin (using Plugins > Admin tool), then you can make sure your file has the right UDL active, then use Plugins > EnhanceAnyLexer > Enhance Current Language to edit the plugin’s config file. You can then define foreground color changes using “0xBBGGRR = regex” pairs.

    32d726da-3676-466c-b50b-0f889bb555b6-image.png

    [udf] ; color each word, 0x66ad1 is the color used, see the description above for more information on the color coding. 0x0080FF = \([^)\\]]*?\) 0x0080FF = \\[[^)\\]]*?\\] 0x00FF80 = \([^)\\]]*?\\] 0x00FF80 = \\[[^)\\]]*?\) ; check in the respective styler xml if the following IDs are valid excluded_styles = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,20,21,22,23

    In my example, I defined four regular expressions: two will match the balanced [...] and (...); the other two match the imbalanced [...) and (...]

    If you don’t want it to match multiline, change each of those four regex to have \r\n right after the ^, so that it doesn’t look for parenthesized text that spans across newline characters.

    note: mine used [udf] as the header, because I was in an unnamed UDL. If you follow my instructions above, yours will have [YourUdlNameHere] instead.

  • Default User Defined Language ?

    7
    0 Votes
    7 Posts
    2k Views
    Bobbster LobsterB

    Very old thread, but little hack-around I found. Suppose you want .md to be the default extension (and assuming your current default language is “None (Text)”:

    open langs.xml just add the md extension to the “normal” language, i.e. <Language name="normal" ext="md txt"/>

    Now md will be the default extension!

    By the way thanks @PeterJones for your md UDL!

  • Change Autocomplete background color

    14
    0 Votes
    14 Posts
    2k Views
    Mark OlsonM

    This is kind of necroposting, but I just wanted to share a PythonScript script I made that hopefully makes it reasonably easy to improve the contrast of the autocompletion list selected line.

    # https://community.notepad-plus-plus.org/topic/20320/change-autocomplete-background-color/13 from __future__ import print_function from Npp import * def caret_line_and_selection_back(): ''' WORDSTYLESUPDATED notifications don't give anything like style names when they fire so we identify each style by a tuple of (caret line back, selection back) which is hopefully unique to that style. ''' return (editor.getElementColour(ELEMENT.CARET_LINE_BACK), editor.getElementColour(ELEMENT.SELECTION_BACK)) class ALSMCT(object): def __init__(self): self.off = False self.style_list_defaults = {} def reset_autocomp_list_colors(self): caret_selback = caret_line_and_selection_back() list_defaults = self.style_list_defaults.get(caret_selback) if list_defaults and 'back' in list_defaults and 'fore' in list_defaults: list_default_fore = list_defaults['fore'] print('resettting autocompletion list fore to style default %s' % (list_default_fore,)) editor.setElementColour(ELEMENT.LIST_SELECTED, list_defaults['fore']) list_default_back = list_defaults['back'] print('resettting autocompletion list back to style default %s' % (list_default_back,)) editor.setElementColour(ELEMENT.LIST_SELECTED_BACK, list_defaults['back']) else: # couldn't find current style, so just use global defaults print('resetting autocompletion list colors to global defaults') editor.resetElementColour(ELEMENT.LIST_SELECTED) editor.resetElementColour(ELEMENT.LIST_SELECTED_BACK) def on_wordstyles_updated(self, notif): # map current (caret line back, selection back) (which this script doesn't change) # to LIST_SELECTED and LIST_SELECTED_BACK (which it does change) # that way we can later restore the defaults for the current lexer. # Note that editor.resetElementColour just resets to global defaults # NOT the default for the current style caret_selback = caret_line_and_selection_back() list_selected_defaults = { 'fore': editor.getElementColour(ELEMENT.LIST_SELECTED), 'back': editor.getElementColour(ELEMENT.LIST_SELECTED_BACK) } self.style_list_defaults.setdefault(caret_selback, list_selected_defaults) print('default autocompletion list style is %s when caret line back is %s and selection back is %s' % (*caret_selback, list_selected_defaults)) # now change the list styles to caret line styles (if not ALSMCT_OFF) self.on_bufferactivated(notif) def on_bufferactivated(self, notif): if self.off: return caret_line_back = editor.getElementColour(ELEMENT.CARET_LINE_BACK) list_fore = editor.getElementColour(ELEMENT.LIST) # match list fore color to caret line fore color as well to avoid low contrast # (since default LIST_SELECTED may be similar to CARET_LINE_BACK) print('setting autocompletion list back color to %s' % (caret_line_back,)) editor.setElementColour(ELEMENT.LIST_SELECTED_BACK, caret_line_back) print('setting autocompletion list fore color to %s' % (list_fore,)) editor.setElementColour(ELEMENT.LIST_SELECTED, list_fore) if __name__ == '__main__': try: alsmct.off = not alsmct.off # running script multiple times toggles it if alsmct.off: alsmct.reset_autocomp_list_colors() else: alsmct.on_bufferactivated({}) except NameError: alsmct = ALSMCT() alsmct.on_wordstyles_updated(1) notepad.callback(alsmct.on_bufferactivated, [NOTIFICATION.BUFFERACTIVATED]) notepad.callback(alsmct.on_wordstyles_updated, [NOTIFICATION.WORDSTYLESUPDATED])

    Running the script changes the autocompletion list style as follows:

    running it an odd number of times (including once) causes the text color for the selected autocompletion line to match the text color for the other autocomp lines, and causes the back color of the selected autocomp line to match the back color of the caret line in the document.
    5d506c34-392c-4ad8-93d9-89975828cb87-image.png running it an even number of times resets the style for the selected autocompletion line restores it to the defaults for the theme.
    4f6af084-acca-46c7-a012-3ae2dbe33f1d-image.png
  • any way to recover my data saved in notepad++ in my previous window

    2
    0 Votes
    2 Posts
    2k Views
    PeterJonesP

    @Anas-Ibrahim ,

    You don’t tell us anything about how you lost that data:

    did you close the tab or close Notepad++ and tell Notepad++ that you didn’t want to save? If so, it did what you told it, and didn’t keep that information anymore did you have an OS crash? if so, then the OS probably stopped letting Notepad++ take action, so Notepad++ may not have been able to save, despite trying to. (Look to see if %AppData%\Notepad++\nppLogNulContentCorruptionIssue.log exists; if so, you might be able to share that with the developers, to help them see if they can improve Notepad++'s behavior to try to overcome aggressive OS crash problems.) did you close a saved file, and just don’t know where it was saved? or did Notepad++ forget that you had that file open-but-saved, and you’ve just forgotten where it was? The File menu’s “Recent Files” section will allow you to re-open recently-closed-files, unless Notepad++ has forgotten those, too

    Unfortunately, while Notepad++ has certain features to try to save unsaved data, and can be made to do more to make true backups by using the backup-on-save feature or the AutoSave plugin – see our FAQ:

    it will describe those features in more detail, so that you can take an active role in taking responsibility for your critical data by setting those to better work with your workflow, hopefully avoiding data loss in the future it gives ideas as to where to look for the current location of backup files, like telling you that the “unsaved data” might be in a file in the %AppData%\Notepad++\backup\ folder it mentions an external file recovery application which may help you recover lost data (though we make no guarantees)

    I’m sorry for your loss.

  • Freezing, slow on (somewhat) large files lately

    4
    0 Votes
    4 Posts
    922 Views
    gstaviG

    @AndersWa said in Freezing, slow on (somewhat) large files lately:

    Just now opening a 1.3 MB XML file, it takes about 20 seconds to open the file and for N++ to become “active” again, after that editing a few elements in the XML and scrolling through it

    Large files and syntax highlighting does not work well together.
    Syntax highlighting is designed for hand crafted files. The highlighting help the writer. It is costly to compute but the cost is unnoticeable on modern CPUs for a few thousands of line.
    Large files are auto generated. The generator does not need syntax highlighting. The cost of highlighting 100 thousand lines and re-highlighting them for every edit is huge.
    Change the language to Normal text (disable highlighting).

  • User Defined Language: what do I do wrong ?

    6
    0 Votes
    6 Posts
    899 Views
    PeterJonesP

    @Hans-Troost said in User Defined Language: what do I do wrong ?:

    My apologies for not reacting to you up to now: I think I did not configure my email-notification correct and I was waiting for email notifications. Sorry, sorry…

    This forum software rarely correctly handles email notifications, even if you think you have them turned on. It’s best just to come back and check for yourself.

    but in the 1st reference the word Intellisense is mentioned but better reading: the implementation is less than that, but at least “Autocomplete”. I will try that again, after this better reading.

    We in the Notepad++ Community Forum have no control over a blog written on some other site; if they are providing misinformation about Notepad++, there’s nothing we can do there. “IntelliSense” is Microsoft’s implementation of “intelligent code completion”, and that trademark is owned by Microsoft. No other company is allowed to use that term for their own product (and any that do are likely to get a trademark infringement lawsuit), and any blogger who uses it as a generic term for auto-completion or even for intelligent code completion has misunderstood what “IntelliSense” is.

    Notepad++ only does auto-completion, it doesn’t have “intelligent code completion” by default (though there are plugins that are being slowly developed which will hopefully allow Notepad++ to connect to LSP servers, which may eventually enable more intelligent code completion). So for now, you have to follow the instructions I linked in order to manually set up a Notepad++ auto-completion file for your M UDL.

    2nd Question: about the position of the M Language (the UDL) in the menu. Is’nt that strange? Anyone of you an idea? Of course I can live with it, I’m just surprised with this behavior.

    I thought that was pretty clearly answered above: no, it’s not strange. All the built-in languages go above the horizontal line in the menu, sorted alphabetically. All user-defined languages (UDL) go below the line. That way, you can tell whether the active language for your file is built-in (if it’s above the line) or a UDL (below the line). It’s done on purpose, and will not be changed.

  • Can't save new files after the update

    7
    0 Votes
    7 Posts
    924 Views
    TBugReporterT

    @Damon-Bush

    No offense meant; I was just pointing out a common mistake that many users make, for the benefit of those that don’t know better. (Also for their benefit: it can seem logical to keep the data files produced by a program alongside the program itself, but it increases the chance of a user altering or removing essential files, which is why Windows tries to prevent this. Of course, an Administrator account can do almost anything - which is why users shouldn’t use Administrator accounts for anything other than administrative tasks.)
    I realize that this is far off topic for this discussion, but I’m sure that a significant percentage of the people reading this in the future will be unaware of what I just wrote.

  • How to make punctuation correctly in SRT file

    8
    0 Votes
    8 Posts
    1k Views
    CoisesC

    @Mohamed-Mohamed Just a thought: have you checked to see if the Fix common errors feature in Subtitle Edit, with proper adjustment at Options | Settings… | Tools | Edit settings for fixing continuation style… | Edit custom continuation style… can do what you want more easily? I haven’t used those settings, so I can’t advise in any detail, but it is a purpose-built tool for editing and correcting subtitles.

  • I need to delete anything before ANY number, AND the number in a line

    5
    0 Votes
    5 Posts
    1k Views
    greg gregG

    @Terry-R thanks Terry, I didnt even bothered to do it all, I just searched for (?-s).+\d+\s and replaced with nothing. worked like a charm, no backfiring at all, not even those 0,01% I was expecting to have.

  • Non-existent files (tabs) disappear on program launch

    7
    0 Votes
    7 Posts
    561 Views
    TeasyT

    @Alan-Kilborn
    is shooting down people trying to help this program a hobby of yours?
    or do you get paid for it?

    Edit: can someone report this guy?
    (i don’t have enough “reputation” points on this forum)
    reading his post history shows overly negative tone
    shooting down people on a regular basis
    which i’m certain does not improve the quality of the product nor its community!

  • Regex use

    14
    0 Votes
    14 Posts
    19k Views
    guy038G

    Hello, @mkupper and All,

    @mkupper, thank you for your appreciation !

    First, I would say that the \C and \X syntaxes are far from noob regex syntaxes !

    The \C syntax, as said in my previous post, should detect individual bytes of an UTF-8 file but, actually, returns the current NON-EOF character just like the well-known (?-s). syntax

    The \X syntax matches :

    Any single Non-diacritic character

    0 or more associated diacritic characters, following the Non-diacritic char

    For instance, the regex --o\x{0306}\x{0320}\x{0340}--o\x{0318}\x{0346}\x{0305}-- would exactly match the 14-chars string --ŏ̠̀--o̘͆̅-- and could be replaced by the regex --\X--\X--. Just enlarge the characters to their maximum for good readability ! However, note that the simple 8-chars string -------- would also be matched by the --\X--\X-- regex !

    Secondly, I must admit that talking about Unicode characters, in a general way, made me drift towards my Total_Chars.txt file discussion !

    But, even if we use the previous THEORICAL syntax, against the Total_Chars.txt file :

    (?xs) ( (?| (?= [\x{0000}-\x{007F}] ) (\C) ( ) ( ) ( ) | # 128 1-byte chars in part INSIDE the BMP | (?= [\x{0080}-\x{07FF}] ) (\C) (\C) ( ) ( ) | # 1,920 2-byte chars , in part INSIDE the BMP | 63,454 chars (?= [\x{0800}-\x{FFFF}] ) (\C) (\C) (\C) ( ) | # 61,406 3-byte chars , in part INSIDE the BMP | (?= [\x{10000}-\x{1FFFFF}] ) (\C) (\C) (\C) (\C) # 262,136 4-byte chars , in part OUTSIDE the BMP, with code > \x{FFFF} ( = 4 × 65,534 ) ) )

    We could NOT find any result for two reasons :

    The \C regex does not work with our present Boost regex engine ( See above )

    The characters over \x{FFFF} are not properly handled by the Boost regex engine

    So the last line (?= [\x{10000}-\x{1FFFFF}] ) (\C) (\C) (\C) (\C), regarding characters outside the BMP, should be changed as (?s).[\x{D800}-\x{DFFF}]

    Using this regex, against the Total_Chars file, in the Find dialog, with the Wrap around button checked, does return 262,136 characters, when you click on the Count button

    You may also convert this regex in a range delimited by two surrogate pairs as character boundaries

    Open the Mark dialog ( Ctrl + M )

    Untick all box options

    Enter the regex \x{D800}\x{DC00}.+\x{DB7F}\x{DFFD} ( first char of Plane 1 to last allowed char of Plane 14 )

    Tick the Purge for each search and Wrap around options

    Select the Regular expression search mode

    Click on the Mark All button ( 1 hit )

    Click on the Copy Marked Text button

    Open a new file ( Ctrl + N )

    Paste the contents of the clipboard

    Again, using the (?s).[\x{D800}-\x{DFFF}] regex on the entire file or a simple Ctrl + A gives a count of 262,136 characters for this new file !

    Thirdly, I would like to insist on the fact that, both, the LastResort-Regular.ttf font and the Total_Chars text file deal only with characters and NOT with the individual bytes of these chars, depending of their current encoding !

    So, in a sense, it’s not connected to the beginning of my initial post, regarding individual bytes. Sorry for the confusion !

    Best Regards,

    guy038

  • default page

    8
    0 Votes
    8 Posts
    706 Views
    mkupperM

    @Coises said in default page:

    HKCR.txt\ShellNew

    Thank you. The puzzle for me is that I don’t have a HKCR\.txt\ShellNew key. Granted, I can create one.

    However, I was trying to figure out is how and why “Text document” is available in Windows explorer’s “New” button list and right click list. I have 11 choices available for “New.” For ten of them I saw the ShellNew subkey and the values used to create new files. Those all made sense to me. The missing or invisible key of the 11 was whatever mechanism is used for new “Text document”.

    I ran a profiler on explorer.exe and see that it’s building the New list out of a cache and that it pulled the information related to “Text Document” out of the resources for Notepad.exe ms-resource://Microsoft.WindowsNotepad/Resources/ShellNewDisplayName_Txt. I’m guessing that because I left the Windows 11 Notepad.exe store app installed that it tells Windows Explorer to add itself to the new list.

  • Style/theme settings lost on every N++ update

    9
    0 Votes
    9 Posts
    1k Views
    DeklatisD

    So I finally updated mine, I think it was 8.4.8. I don’t usually update cause it’s always open. I took all the defaults, just kept clicking, then it opens to blinding white. I sort of started to panic because I haven’t changed or even checked my settings in a very long time. I didn’t even know what theme I was using. I looked in AppData location and themes and found the one that had been the most recently modified (2020), and it seems to be the one (I hope). Still it was quite a shock lol.

  • FIND/SEARCH not showing the results

    3
    0 Votes
    3 Posts
    324 Views
    PeterJonesP

    @gocorona-go ,

    This FAQ was added today because this question is starting to come up frequently enough to warrant its own FAQ entry.

  • How to Navigate to a Parent Directory in the Folder as Workspace

    2
    0 Votes
    2 Posts
    180 Views
    PeterJonesP

    @Bernard ,

    Folder as Workspace (“FaW”) uses the Folder you choose as the Workspace as the root/top-level of what it display. You cannot use it to navigate “above” that root.

    If you want generic directory navigation through a panel similar to the FaW, what you probably want is the Explorer plugin (available to install through Plugins > Plugins Admin interface), which allows you to navigate to any directory in your filesystem, rather than using a fixed folder as the root of what you see in FaW.

  • Add text to end of line

    5
    0 Votes
    5 Posts
    489 Views
    DoğancanD

    @PeterJones Now I understand. I can edit the code you gave. So much detail is unnecessary for me.

  • Help - Remove a line from a specific text but keep a part of the text

    10
    0 Votes
    10 Posts
    2k Views
    L ML

    @PeterJones Thanks it’s working now.

    I also figured out some occurences had only the CR from this answer:
    https://community.notepad-plus-plus.org/post/17010

    And could modify as this to accomodate:
    Find: \r(\sIV,)
    Replace: ($1)

  • Let Comment Flags Keep Aligned

    2
    0 Votes
    2 Posts
    184 Views
    TBugReporterT

    Here’s what I do for this. Add this to the <Macros> section of your shortcuts.xml file:

    <Macro name="Col. 1 Remark" Ctrl="yes" Alt="yes" Shift="no" Key="75"> <Action type="0" message="2349" wParam="0" lParam="0" sParam="" /> <Action type="1" message="2170" wParam="0" lParam="0" sParam="REM " /> </Macro>

    Key 75 is the letter K, so this adds a Ctrl-Alt-K keystroke to your configuration (you said Ctrl-Q, but my solution isn’t a toggle like that keystroke; if you want Ctrl-Alt-Q, change 75 to 81); message 2349 says to go to the beginning of the line (unconditionally, i.e. not just the beginning of the text on the line); and message 2170 says to type the given text - REM and a space (the forum won’t let me show the space in red here). If you edit other types of files this way, you can change to the comment string for whatever language you’re using, and assign a different key for that one.