• Search for inconsistent line endings with a regex? (part 2)

    29
    3 Votes
    29 Posts
    5k Views
    guy038G

    Hello, @ekopalypse, @alan-kilborn and All,

    I did some additional tests, with your modifications, Alan :

    line_of_first_mismatch = editor.lineFromPosition(match.span(0)[0]) notepad.messageBox('Different EOLS detected -- the first inconsistency is on line ' + str(line_of_first_mismatch + 1),'EOL Mismatch', 0)

    and my own one :

    false_EOL = {0:'$\n|\r^', # Find \n AFTER end of line OR \r BEFORE beginning of line as editor.getEOLMode() = 0 ( Windows EOL )

    And everything seems to work as expected !

    So the final version of this script is :

    check = True false_EOL = {0:'$\n|\r^', # Find \n AFTER end of line OR \r BEFORE beginning of line as editor.getEOLMode() = 0 ( Windows EOL ) 1:'\n', # Find \n ( should be \r ) as editor.getEOLMode() = 1 ( Macintosh EOL ) 2:'\r', # Find \r ( should be \n ) as editor.getEOLMode() = 2 ( Unix EOL ) } def check_eol(match): global check check = False line_of_first_mismatch = editor.lineFromPosition(match.span(0)[0]) notepad.messageBox('Different EOLS detected -- the first inconsistency is on line ' + str(line_of_first_mismatch + 1),'EOL Mismatch', 0) user_input = notepad.prompt('Convert ALL line-endings of CURRENT file ( 0 for CRLF, 1 for CR, 2 for LF )', 'INCONSISTENT line-endings DETECTED !', editor.getEOLMode()) if user_input is not None: desired_eol_index = int(user_input) if 0 <= desired_eol_index <= 2: eol_cmd_list = [ MENUCOMMAND.FORMAT_TODOS, MENUCOMMAND.FORMAT_TOMAC, MENUCOMMAND.FORMAT_TOUNIX, ] if desired_eol_index == editor.getEOLMode(): notepad.menuCommand(eol_cmd_list[(desired_eol_index + 1) % 3]) # change to UNDESIRED line-endings notepad.menuCommand(eol_cmd_list[desired_eol_index]) # change to DESIRED line-endings editor.research(false_EOL[editor.getEOLMode()], # regex to search for check_eol, # function to call if regex match 0, # re flags 0, # START of file editor.getLength(), # END of file 1) # count ( at FIRST match ) if check == True: notepad.messageBox('All EOLS correct','EOL check', 0)

    To be rigorous, note that the first EOL inconsistency is always the first line with line-ending chars(s) different from the status bar indication !

    Best Regards,

    guy038

  • Macro Menu commands and the Context Menu

    7
    1 Votes
    7 Posts
    671 Views
    Alan KilbornA

    @Jim-Dailey said in Macro Menu commands and the Context Menu:

    And, as you have pointed out, even if they are on the Macro Menu, the context menu doesn’t “see” them there, but rather on the NPP Exec Menu.

    It’s a bit odd, because when they are configured to be on the Macro menu, they don’t appear on the NppExec plugin menu, so I’m not sure how they’re actually found. Curious.

  • f5 run...go to next line or next character?

    5
    0 Votes
    5 Posts
    529 Views
    ddalthorpD

    @PeterJones Almost certainly true. Thanks. npptoR has not been updated since 2016.

  • Header plugin

    4
    0 Votes
    4 Posts
    629 Views
    Aleksandr ShchepkinA

    Friends, you’ve helped me so much, I’m so happy. I have a txt file with more than 16000 lines, size 1,6 mb. I created an xml file in the functionList folder with the following code:
    <NotepadPlus>
    <functionList>
    <parser displayName=“XML” id=“xml”>
    <function
    mainExpr=“#([^#<]+)”
    displayMode=“$functionName”>
    </function>
    </parser>
    </functionList>
    </NotepadPlus>

    And indeed now, I have a set of headers displayed on the right (the headers start with the # symbol).
    The file is constantly growing, so far everything is working very well, thanks.

  • I can't save it... help me plz...

    2
    0 Votes
    2 Posts
    220 Views
    PeterJonesP

    @parkyungmin ,

    Sorry. I could not reproduce it. “Save” and “Save As” work for me.

    ----

    Why such a short reply? Because you didn’t tell us enough to be able to reproduce your problem, or because I tried what you described and got the results I expected. If you give us more information, we might be able to help more. Especially important are the ? menu’s Debug Info contents, a thorough description of the steps necessary to reproduce your problem.

  • Forced font antialiasing and Courier is not what it should be

    8
    0 Votes
    8 Posts
    659 Views
    Jean-Claude ArbautJ

    @Alan-Kilborn

    Actually, as long as the option is still there it’s fine. But it was surprising, as there is also an antialiasing option in the Editing pane, so I didn’t expect another option to cover this (and I rarely look at the Misc pane anyway).

    I guess whatever the enhancement, there will always be someone who doesn’t like it. ;-) I have myopia, and I see blurry enough, so I like my screen characters to be as sharp as possible. While it may not be a common concern, I’m sure I have seen folks with the same preference on the Internet from time to time, as my antialiasing problem is not new nor limited to Npp - Windows and other programs have not always been reliable for this either. Even on Linux, I tend to prefer xterm over the more modern terminals for the same reason. I’m in the anti-antialiasing team!

    Many thanks to all,

    JCA

  • Why does this regexp fail to match?

    8
    0 Votes
    8 Posts
    425 Views
    mkupperM

    @Alan-Kilborn said in Why does this regexp fail to match?:

    It’s so contrived it makes my head hurt. :-P
    I suspect this is the non-contrived version (which feels much better):

    I agree on the hurt, or at least spinning, head. In hindsight, I should have used ^date\K time which both works and is easier to mentally parse.

    I now understand why my first expression failed in the original message on this thread.

    FWIW, while parsing @Coises’ reply I found https://www.regular-expressions.info/lookaround.html via Google that has a decent explanation on why many regexp engines require fixed length or width lookbehinds. Some engines have ways around this restriction but each of those seems to create their own cans of worms.

    For now I’ll stick with lookbehinds only as the first thing in an expression or use \K as I now see that if I have a lookbehind later in an expression, even after a zero length ^ match, that it can be a brain twister to figure out what is happening.

    Here’s a simplified version of the contrived data and regexp that is easier to understand. The data is

    abc

    Searching using any of these get you the same results:

    (?<=a)bc b(?<=ab)c bc(?<=abc)

    The latter two end up inspecting the b or bc in the data twice.

  • 0 Votes
    4 Posts
    734 Views
    Gary HessG

    Sorry, I figured it out. “Wrap around” wasn’t checked.

  • After using Compare, how do you save differences?

    3
    0 Votes
    3 Posts
    7k Views
    Jacqueline van der WalJ

    @pnedev Thank you very much, I will try this! This is my work laptop on which I don’t have admin rights, so I will need to have someone install this for me. Thanks a lot!

  • How can I go to a specific column?

    15
    0 Votes
    15 Posts
    8k Views
    Alan KilbornA

    I’m starting to think that the notion of a “column” number value is a ridiculous concept. :-)

    Moving away from regular expressions, here’s a PythonScript for experimentation, that will prompt you for a column number to move the caret to on the current line.

    # -*- coding: utf-8 -*- from __future__ import print_function # references: # https://community.notepad-plus-plus.org/topic/25579/how-can-i-go-to-a-specific-column # 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 from Npp import * current_line = editor.lineFromPosition(editor.getCurrentPos()) max_column = editor.getColumn(editor.getLineEndPosition(current_line)) while True: if max_column == 0: notepad.messageBox('Current line is empty (has no columns)', '') break user_input = notepad.prompt('Enter column (1 - {mc}) to move caret to (on current line):'.format(mc=max_column+1), '', '') if user_input is None: break try: desired_column = int(user_input) - 1 if not (0 <= desired_column <= max_column): raise ValueError except ValueError: continue pos_of_desired_col = editor.findColumn(current_line, desired_column) gc = editor.getColumn(pos_of_desired_col) if desired_column > gc: notepad.messageBox('desired column ({dc}) is greater than existing column ({gc}) on current line; moving to column {gc}'.format( dc=desired_column+1, gc=gc+1), '') editor.setSel(pos_of_desired_col, pos_of_desired_col) break

    Note that this does NOT implement any of the grand ideas I had EARLIER for a well-rounded-out “goto line/col” feature (maybe a script for that comes later if we can find a way beyond “weird” column results with some of the stranger unicode characters…).

  • search list values in 50+ files

    4
    0 Votes
    4 Posts
    606 Views
    Alan KilbornA

    @mkupper said in search list values in 50+ files:

    I normally do that from the command line. Notepad++'s search can’t use a list of thousands of values.

    You should have stopped after those 2 sentences.
    Please don’t present detailed non-Notepad++ solutions to questions posed on this site.
    This site is for discussion of Notepad++ related topics, only.

    If you feel like you want to suggest a non-Notepad++ solution to something, perhaps the best reply is suggesting some keywords for an internet search the poster could do to arrive at some help.

  • clear and close Search Results

    7
    0 Votes
    7 Posts
    553 Views
    TBugReporterT

    @Alan-Kilborn said in clear and close Search Results:

    by “confused” you mean that when running the script from one instance, that it might close a different instance’s Search results. […]

    In my understanding, there is nothing that prevents this from finding the “wrong” instance window

    My concern exactly, but as I said, experimentation hasn’t caused this to occur for me yet.

    I’ve never undocked the panel; I don’t even know how to do that.

    If you double-click either of these areas

    Thank you for the extra effort, but I didn’t mean that comment as a question. I saw that info at the manual site, but the only time I expect to use it is if I do this by mistake - to get things back to normal.

  • 0 Votes
    5 Posts
    492 Views
    Alan KilbornA

    @litos81 said in In normal text file, ... and === and <<< are displayed oddly. How to disable?:

    Probably what you were seeing was the ligature (where certain chain of characters are joined in one) support from that font.

    For readers unfamiliar with “ligatures”, in simple terms it is a visual transmuting of adjacent characters.

    Here are some examples, from typical programming languages:

    test for equality: without ligature support it would appear ==; with support it looks like this:
    cd9c8b92-3a60-4f25-ad63-f51743752655-image.png

    test for inequality: without ligature support it would appear !=; with support it looks like this:
    199bf85b-c607-4b93-b6d2-f8a068e069af-image.png

    if you put three equal signs together (===), you can get this:
    e96f3f13-bd02-47f1-a9a0-b9ede337ccff-image.png

    All the examples I’ve shown use the equal sign in them, but ligatures go way beyond that (using other character combinations).

  • Secondary carets not visible with dark theme

    12
    1 Votes
    12 Posts
    1k Views
    rdipardoR

    @JTB-Ben_Sync said in Secondary carets not visible with dark theme:

    Is it possible for this to be added into notepad++ fresh install?

    As a matter of fact, it was added to all the standard-issue themes in time for the “Anniversary Edition” (8.6.0) last November.

    Have a look at this related GitHub issue and consult the user’s manual on how to completely refresh your user configs after a feature upgrade.

  • put search result right in the middle of screen

    15
    0 Votes
    15 Posts
    2k Views
    Auryn MeA

    I got progress :)
    I found a JSON Formatter / Validator that formatted that mess from above to this:
    0c957bdb-81df-457e-8f99-4689fedeafd2-image.png
    Look much more easy to work with, the game accepts it and i can use Notepad++ :)

  • Why cant i go over <H6> when doing headings?

    3
    0 Votes
    3 Posts
    211 Views
    _erinaa__

    @PeterJones Thanks a lot!!

  • Disable menu activation for a shortcut.

    18
    0 Votes
    18 Posts
    5k Views
    notdodgeballN

    Continuing the trend of the user is actually the problem, I have several custom Alt+something shortcuts and the menu bar options don’t interfere with them at all.

    It gets better, if I let go of the Alt key and then press the letter I can still use the menu bar shortcuts normally, as if I had pressed the F10 key to bring the focus to the menu bar, which would be my fallback option anyway.

  • COBOL syntax and wrap strings

    4
    0 Votes
    4 Posts
    508 Views
    R

    @Alan-Kilborn

    Thank you. I did add the request on the Scintilla site.

  • 0 Votes
    3 Posts
    471 Views
    menbead1M

    @rdipardo thank you, deleting langs.xml as well as stylers.xml fixed the issue! thank you so much!

  • 0 Votes
    6 Posts
    742 Views
    Alan KilbornA

    @Lycan-Thrope said in does anyone know a alternative for a chromebook that works like Notepad ++:

    responding to a 4 year old post

    This is okay, as long as you’ve got something valuable to say.