• how to view the line separately where curly bracket are used

    8
    0 Votes
    8 Posts
    796 Views
    Mark OlsonM

    @PeterJones
    FWIW, if all you want is to pretty-print or compress the results of a regex search with PythonScript, you could replace the call to JsonTool’s pretty-print faculty with a quite simple script using Python’s json library.

    import json from Npp import editor PRETTY_PRINT_INDENT = 4 class CompressOrPrettyPrintRegexSearchResult: def __init__(self, compress): self.compress = compress def callback(self, m): parsed_group_2 = json.loads(m.group(2)) indent = None if self.compress else PRETTY_PRINT_INDENT formatted_group_2 = json.dumps(parsed_group_2, indent=indent) return m.group(1) + formatted_group_2 + m.group(3) if __name__ == '__main__': try: COPPRSR except NameError: COPPRSR = CompressOrPrettyPrintRegexSearchResult(True) editor.rereplace('(?s-i)(<fieldMap[^<>]*>)(.*?)(</fieldMap>)', lambda m: COPPRSR.callback(m)) # this will toggle between compressing and pretty-printing COPPRSR.compress = not COPPRSR.compress
  • How to Insert/Import Text from a Separate File

    2
    0 Votes
    2 Posts
    3k Views
    Alan KilbornA

    @AcmeNuclear said in How to Insert/Import Text from a Separate File:

    Does Notepad++ have an easier way to make this text file insertion into the current file - without executing something similar to Open (source file), Select all (source file); Copy; Select target location (receiving file); Paste; Close (source file)?

    Not really.
    But if you’re willing to use a scripting plugin, a simple script can be written:

    from Npp import * import os f = notepad.prompt('Enter file name:', '', '') if f and os.path.isfile(f): notepad.open(f) editor.selectAll() editor.copy() notepad.close() editor.paste()

    The script assumes you have the “MRU” setting selected (otherwise when the script closes the file tab it opens, you won’t be returned to the correct file tab):

    de7fbf65-50c8-42ec-bed9-ec4e218fe5ed-image.png

    And, yes, this script is very simple. It intentionally loads the file into Notepad++ (instead of just reading the file with Python) to avoid making non-Notepad++ assumptions about the encoding of the file, it expects you to know the name of the file you want (instead of a “picker”), it will close the to-be-inserted-file if that file happens to be open in N++ when the script is run, etc.). Many things could be done to make the script more well-rounded.

    For the basics of scripting, see HERE.

  • Add folding rules to an existing language

    3
    0 Votes
    3 Posts
    443 Views
    E

    @PeterJones oh… that seems not feasible, udl was a quite better option. Thank you for helping me make a quick decision.

  • Replace guid with guid from list randomly

    2
    0 Votes
    2 Posts
    608 Views
    Mark OlsonM

    The regex gurus on this forum might come up with some kind of crazy regex-based solution to this, but this is pretty easy to solve with PythonScript.

    # requires PythonScript: https://github.com/bruderstein/PythonScript/releases # ref: https://community.notepad-plus-plus.org/topic/25388/replace-guid-with-guid-from-list-randomly import random import re from Npp import editor, notepad, MESSAGEBOXFLAGS def main(): thing_to_replace = notepad.prompt('Enter the text you want to replace', 'enter text to replace', '') if not thing_to_replace: return is_regex = notepad.messageBox( 'Is the thing you want to replace a regular expression?', 'regular expression?', MESSAGEBOXFLAGS.YESNO) == MESSAGEBOXFLAGS.RESULTYES if not is_regex: thing_to_replace = '(?-s)' + re.escape(thing_to_replace) replacements = notepad.prompt( 'Enter a list of replacements (one per line)', 'list of replacements', '') if not replacements: return replacement_list = replacements.strip().splitlines() def get_random_from_list(_): return random.choice(replacement_list) editor.rereplace(thing_to_replace, get_random_from_list) if __name__ == '__main__': main()
  • save repeat operations in a script?

    19
    0 Votes
    19 Posts
    782 Views
    Furio SassiF

    @mkupper said in save repeat operations in a script?:

    @Furio-Sassi said in save repeat operations in a script?:

    Do you happen to know a text editor that supports scripts?

    Notepad++ has syntax highlighting for scripts but won’t offer help or hints as you are typing.

    There are editors known as IDE “integrated development environment” which allow you to single step through the script with the IDE also showing you what variables are being changed. It’s an area I’m not familiar with and particularly, an IDE that would let you trace or debug a Python script activated from Notepad++ and is doing Notepad++ and/or Scintilla specific things.

    Everything clear, thanks for the help! :)

    And I would also like to make peace with those I argued with, in the world there are so many reasons to argue that it would be stupid to argue even over something stupid like that. I came here in complete good faith, before writing I had also looked for information on macros (as I specified in my second post where I wrote “the macro, if I understand correctly, repeats the recorded operation”) but I had not found any references to scripts , that’s why I asked for help. Then the discussion took a direction I didn’t want.

    Thanks everyone, bye :)

  • Save As takes an other folder then the oriiginal

    3
    0 Votes
    3 Posts
    252 Views
    Arne EverhardA

    @Alan-Kilborn Thank you very much.

  • How to compare & remove all multiple blocks of lines?

    4
    0 Votes
    4 Posts
    522 Views
    Dean-CorsoD

    Hi again,

    thanks for your help guys. So it seems to work using your method @Coises to set # or ## and to change all blocks into single lines. Very good idea and I think it did everything correctly so far on the first quick view.

    @Mark-Olson, just wanted to find & remove all double / multi blocks which are same. The 2 blocks I have posted above are not same so just double them etc. Otherwise the solution from @Coises works pretty well so far to manage & handle that problem for me and now I can merge all files I have into one single file and clean it up so that every block is only present once.

    PS: By the way, just have a small another question about that combination of commands. I would like to create a macro of it. Just wanna know whether I have to enter every single char again each time when I record the macro? I mean this for example “(?<!>)\R(?!<$)”. So what is if I have a larger amount of chars I need to use many times? Do I have to enter it again & again char by char etc?

  • Find and replace except if string contains charecter

    5
    1 Votes
    5 Posts
    290 Views
    Pinto IslamP

    @Coises
    This worked perfect. After I posted, I was doing similar steps, but turns out I put the () in the wrong place and wasn’t getting the right result. Appreciate your help.

  • How to open local git file in remote git in browser?

    4
    0 Votes
    4 Posts
    1k Views
    batagyB

    Okey, now I made it to work.

    Solution:

    Install git-url helper script, according to the readme in that.
    This is a bash script but runs also on Windows if Git Bash installed. Install NppExec plugin to Notepad++ Use below NppExec script , save it to a name like “OpenGitInBrowser” NPP_CONSOLE 0 NPE_CONSOLE v+ cd "$(CURRENT_DIRECTORY)" git url "$(FILE_NAME)" npp_run firefox "$(OUTPUT)#L$(CURRENT_LINE)" If you view or edit a file in git repo in Notepad++, press F6, select the above script, and done.

    It will jump to the actual line number in browser, in the given branch. This URL format is compatible with gitlab. Didn’t test with other git repo services,

    It runs hidden (no console opening for NppExec), and it takes some seconds because of bash script, bit working fine.

    :)

  • Can Letters Be Added to the Margin Along with Numbers?

    11
    0 Votes
    11 Posts
    709 Views
    Troglo37T

    @Alan-Kilborn Here’s a pic of the change log. I used Style one token to illustrate how the colors look. It’s turquoise when that line is clicked. Green when not clicked. Notepad++ Styles-Background.png

  • overwrite the stylers.xml file

    4
    0 Votes
    4 Posts
    501 Views
    PeterJonesP

    @DomOBU said in overwrite the stylers.xml file:

    I don’t see how I can manually edit the xml to find my current settings.
    That’s the drawback of the portable version

    If your portable notepad.exe is in c:\portable\npp\, then stylers.xml is at c:\portable\npp\stylers.xml .

    The config files location is documented in the online user manual at npp-user-manual.org . And that same user-manual page has the description of best-practices for editing Notepad++'s config files from within Notepad++.

  • 0 Votes
    11 Posts
    640 Views
    Alan KilbornA

    @Mark-Olson said:

    I came up with…

    Nice one.

    So then a unicode-ready replacement for the native command Remove Empty Lines (Containing Blank Characters) can be a macro, recorded as:

    Find: ^((?![\n\r])[\s\x{FEFF}])*\R
    Replace: nothing
    Search mode: Regular expression
    In selection: Checkmarked
    Action: Replace All

    I checkmark In selection because the original command can either run on the active selection or the entire file; for the macro it is a bit of a difference because to run on the entire file you’d have to Select All (Ctrl+a) first, but that’s not effort-intensive.

  • Change keybind of multi-edit to ctrl+alt+click

    3
    0 Votes
    3 Posts
    663 Views
    Alan KilbornA

    A feature request was made: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/14611

    This is Scintilla behavior, not Notepad++ behavior. It would have to be made configurable via Scintilla before Notepad++ could apply it – thus, it should be a Scintilla feature request.

    EDIT: Well, the Notepad++ could choose to “go rogue” and “hack around” this aspect of Scintilla, like what was done to support “multi-editing” in Notepad++ 8.6 and later. But, I don’t see it happening.

  • I need to add specific keyword at the middle of each 3 lines

    5
    0 Votes
    5 Posts
    906 Views
    mkupperM

    @faridalabib - to add to what @PeterJones just posted another thought is to replace with one keyword but then to do a second pass to “mailmerge” the list of desired keywords in place of the single keyword you had added. See this other post by @PeterJones and its follow-up posts on how to do the mailmerge.

  • How to add specific 2 keywords at the middle of each 3 lines

    Locked
    2
    0 Votes
    2 Posts
    215 Views
    PeterJonesP

    @faridalabib ,

    You already asked that here. There is no need to ask the same question twice (and, in fact, it is considered rude and just makes you look impatient).

    Replies should go in that other Topic, and not here. This Topic is locked.

  • 0 Votes
    8 Posts
    2k Views
    Mark OlsonM

    @sdsds-rgdsfds said in Hover to preview AI (claude) generated alternatives for selected text portions, click to commit changes within surrounding paragraph context:

    Is there other stuff that will help ? I mean out of notepad++

    I’m the wrong person to ask about this sort of thing, to be honest. I am not that familiar with the world of generative AI.

  • custom search more than "one word + delete" possible?

    5
    1 Votes
    5 Posts
    358 Views
    T. H.T

    Hello everyone, I just wanted to let you know that everything worked great. It saved me a lot of work.

    I would like to thank you very much ;-)

    Tom

  • divide article into 50 tabs

    3
    1 Votes
    3 Posts
    236 Views
    mkupperM

    @faridalabib If it’s just 50 articles then you are likely better off doing the split by hand. Doing it by hand should take less time than it would take to figure out how to script splitting a file into 50 parts, debugging it, etc.

    One hint is to number your 50 files from 01, 02, 03, … 49, 50 using leading zeroes for 1 to 9. Then it will be easy to reassemble the 50 files into one large file again to verify that it’s the same as the original large file containing 50 articles.

  • How to add sheets in the same CSV document like you do in Excel

    3
    0 Votes
    3 Posts
    745 Views
    mkupperM

    @HargulS - CSV is a plain text format that can be viewed and edited using Notepad++. The CSV file format does not have, nor can it support, the concept of “sheets.”

    Excel files are containers that hold multiple objects, including sheets which themselves are stored as sets of objects. While the individual objects stored within an Excel file are plain text they contain many cross referenced details between the objects. Spreadsheet applications such as Excel keep track of the details. It’s not practical to edit the object files using Notepad++ as you likely would break the cross referenced details that Spreadsheet applications rely on.

  • is there a way to make delimeter check UP UNTIL closing char??

    3
    0 Votes
    3 Posts
    214 Views
    F

    @supasillyass thanks for the suggestion, but looks like nesting is also not the best solution
    78b4ea44-d918-4cc7-8ec8-b532db7aef28-изображение.png

    Header [ ] highlighting breaks. That’s probably because [HELP2_A] has level 5 nesting, so it would need to encounter 5 ((EOL))s to properly exit.

    Simply inserting newlines helps resolve this, but it makes file look stupid
    b2245093-0e91-49a1-a640-717f18b58307-изображение.png