• How to macro task " find in files"

    May 24, 2023, 4:18 PM
    0 Votes
    2 Posts
    832 Views

    @Tam-LE ,

    Macro recording for searches records the text of the search – it doesn’t notice that you pasted the text into the search field. Sorry. I don’t think a macro is powerful enough for what you want.

    There are scripting plugins, which bring the full power of your favorite scripting/programming language (Python, Lua, JS,…). If you have a preference, I’d suggest installing that plugin and writing a script in that language that runs the appropriate Notepad++ commands. If you don’t know any of those languages, and if someone has enough details from you and enough time and interest, they might be willing to write a quick script for the PythonScript plugin (the most commonly-used scripting plugin in this forum) – but you will have to be more specific as to what you mean by each of your steps, because there’s lots of ambiguity. (For example, you said, “first text value” – but is that a character, a word, a line, a paragraph, a … Each of your brief phrases is way too short for anyone else to be able to help you translate that into code.) Actually, if you have saved your macro, then exit Notepad++, then open %AppData%\Notepad++\shortcuts.xml, and go to your saved macro, and copy all that XML and paste it in here, then select the text in your post and click the forum’s </> button to wrap it so it shows up in a plain text / code box – with the contents of your existing macro, we can get rid of all ambiguity about what you are selecting and copying, and I think there are a some of the regulars here with the skill to both read that macro and to translate those same ideas into PythonScript.

  • Editing Persian text

    Feb 17, 2020, 9:58 AM
    0 Votes
    8 Posts
    1k Views
  • Help or little bug

    May 23, 2023, 9:42 AM
    0 Votes
    3 Posts
    445 Views

    @Andrea-Astolfi-0

    Long known issue; see HERE.
    Not sure it is an issue for everyone, as it doesn’t seem to affect me.

  • 0 Votes
    2 Posts
    231 Views

    @geoslake ,

    Without editing the source code and compiling your own copy of Notepad++ and the libraries it ships with, you are not able to change the logic of the built-in languages like C++. It would be a lot easier to create a User Defined Language (UDL) than it would be to modify the logic for C++.

    I would suggest trying to learn the UDL. You don’t tell us anything about your pseudo-language for your “passwords and things” (whether there are “keywords” you want to have highlighted, whether you use braces for nesting, and that sort of thing), so it’s hard to give you any hints. But the Language > User Defined Language > Define Your Language has a link to its documentation in the dialog box / panel, and that documentation is pretty newbie-friendly, IMO.

    -----
    edt: “don’t treat parentheses as codeblocks start/end” => do you mean () (which are generally called parentheses) or {} (which are often called curly braces or just braces). If you don’t want curly braces to be interpreted as blocks for indentation/folding, then the CPP lexer really isn’t the best choice for you. I really think you need to show us some example text (use the </> in the forum to mark that text as plain text), then paste in a screenshot of the text as highlighted by the lexer, and maybe explain which elements of the highlighting you like, and which you don’t. Because if all you have is a list of keywords that you want highlighted, then the UDL is dead simple: just go to the keywords tab, type those keywords, assign a color in the Style button, and maybe put a default extension for your so that a file with that extension will always use your UDL.

  • 0 Votes
    8 Posts
    4k Views

    Future Readers,

    As mentioned in a 2023 follow-on conversation:

    the “problem” was because ; was defined as the start of a comment for comment-highlighting. The UDL parser doesn’t look for Fold in code 1 or Fold in code 2 keywords for folding when they are contained in Comment lines. Instead, if ; is defined as the start-of-comment-line in the Comment & Number tab, then on the Folder & Default tab, you can define Folding in comment’s open/close pair, and that will allow a special keyword pair to work for folding using comments to start and end the folding. This is true in 2023’s v8.5.3, and this was true in 2016’s v6.9.2.

    Follow-up discussion on this should go in the follow-on conversation rather than in this ancient conversation, which is being locked.

  • 0 Votes
    11 Posts
    2k Views

    @waskoma said in strings starting with “;” ignored when given in codeblock start/end string definition:

    so I have managed to achieve it and am REALLY happy. Gave up solving this a long long time ago (have already asked here and got answer it can not be done)

    in 2016, it looks like you both forgot to come back and follow up on the conversation, so it was never resolved; that’s not quite the same as being told it cannot be done. Under this username, you have no other posts.

    not related to this topic but can I ask more? I have hexadecimal numbers with prefixes $ or #$ and these numbers have abcdef letters in them, they are not recognised as numbers the moment it finds a non numeric character, is there a way to solve that ?

    Prefix 2 is where you put the prefix you want before hex numbers – in your case, $ #$ will allow either $ or #$ as the prefix. Extras 1 is where you put the extra characters that can be a part of a hex number – in your case A B C D E F a b c d e f (the comparison in UDL for that is case sensitive, so if you want it to match upper and lower case for hex digits, you have to include both upper and lower case)

    c31e41d9-04a9-44fe-a47b-fb7001fc4c50-image.png

    BTW: That’s in the UDL docs at https://ivan-radic.github.io/udl-documentation/ – which are linked from the UDL dialog – specifically, on the Numbers page. They give the example of how to make 0xABC work, and from there, you really should have been able to generalize that to make $ABC or #$ABC work.

    also what causes these orange vertical lines show up ? and how to style the codeblock opener closer + and line ? a million thanks :)

    As you discovered, that’s the new Change History feature (v8.4.6), as described in our FAQ.

  • Fixed Format FORTRAN Highlighting

    May 18, 2023, 2:00 AM
    0 Votes
    7 Posts
    1k Views

    @Daniel-Crosby ,

    EnhanceAnyLexer does not change bold/italic/underline, so it cannot do the job. If you change the Style Configurator for the keywords to turn off bold, then the EnhanceAnyLexer color-change should be sufficient for you – though of course, that means that keywords in non-comment lines would just be colorful without any bolding.

  • Restore temp item - Please Help..

    May 21, 2023, 10:48 AM
    0 Votes
    3 Posts
    4k Views

    There’s also the %AppData%\Local\Temp\Notepad++ RECOV folder. The files in that folder will have the .dump extension. Don’t know how reliably N++ will write unsaved files to that folder, but it’s worked pretty well for me recently.

  • Open file...

    May 19, 2023, 12:59 PM
    0 Votes
    5 Posts
    568 Views

    If you edit the properties of the shortcut you use to start Notepad++ and change “Start in:” to the folder you want, File|Open… will use that folder as default until another is established.

  • Search a number grater than

    May 18, 2023, 7:26 PM
    0 Votes
    9 Posts
    3k Views

    @Alan-Kilborn
    With your script as inspiration, I made one that has a different custom search func for each file, allows the user to set the search func with selected text, and the user can choose whether or not to bookmark lines.
    63ddf9b8-22a9-411a-8448-33a055dcf3fa-image.png

    # -*- coding: utf-8 -*- # references: # https://community.notepad-plus-plus.org/topic/24481 from Npp import * import operator import re # Too lazy to parse config files; just modify these global variables instead BOOKMARK_LINES = True class FBOLTN: def __init__(self): self.set_comparator() def set_comparator(self): comparator_regex = re.compile("([><]=?|=)(-?\d+)") sel = editor.getSelText() mtch = comparator_regex.search(sel) if mtch: # user is selecting a new comparator compstr, numstr = mtch.groups() num = int(numstr) else: if hasattr(self, 'comparator'): return # only override current comparator with valid selection # default is what the OP wanted compstr = '>=' num = 25 self.compstr = compstr self.num = num def comparator(other_num): fun = { '>': operator.gt, '<': operator.lt, '=': operator.eq, '>=': operator.ge, '<=': operator.le, }[compstr] return fun(other_num, num) self.comparator = comparator def custom_match_func(self, m): if self.stop: return i = int(m.group(0)) start, end = m.start(0), m.end(0) if self.comparator(i): editor.setSel(start, end) if BOOKMARK_LINES: notepad.menuCommand(MENUCOMMAND.SEARCH_TOGGLE_BOOKMARK) self.stop = True def search(self): self.stop = False editor.research(r'(?<!\w)-?\d+\b', self.custom_match_func, 0, editor.getCurrentPos()) if __name__ == '__main__': try: fboltns except NameError: fboltns = {} cur_fname = notepad.getCurrentFilename() if not fboltns.get(cur_fname): fboltns[cur_fname] = FBOLTN() fboltn = fboltns[cur_fname] fboltn.set_comparator() fboltn.search()
  • 1 Votes
    9 Posts
    988 Views

    @guy038 I didn’t have the chance to thank you very much for your support! It worked very well!

  • 0 Votes
    3 Posts
    782 Views
  • 0 Votes
    4 Posts
    2k Views

    Thank you so much for your prompt help! They both work perfectly!

    Bob

  • Underlining links.

    May 16, 2023, 7:24 PM
    0 Votes
    10 Posts
    836 Views

    @rdipardo ,
    Here’s a perfect example, of what I mean. From my Mother in law, I learned to say that backwards, Bardzo dziękuję. Been a while since the course, so I can’t challenge the translator, but that’s the point. :-)
    It’s dependent on the translation and how it’s getting done. ;)

  • 0 Votes
    18 Posts
    5k Views

    Hey hi @guy038 , I’m coming back to you

    It’s been a busy day between yesterday and today.

    Thanks for the new information. The method you propose is very interesting. Longer and a little more complicated than @Terry-R 's but in the end safer because it is true that when you finalize, there are no mistakes left. Where it can often remain with a numbering system that by dint of being cut and pasted and even sometimes unexpectedly taken in the selection that will pass to the translation, it happens that it gets mixed with the paragraphs. In the end, the time I save with the numbering system, I often lose later to detect and correct the mistakes. Note, this is entirely my fault because I could have or should have made a selection in columns.

    In order not to let your help and efforts go to waste, I used your method on the 10 or so small files I had left and it works very well. Many thanks to you!

    A huge thank you also to @Terry-R , because his method arrived quite quickly. At a time when I was more than tired of editing a 400k file by hand and wanted to give up more than once!

    Finally, thank you all for all this advice @guy038 @Terry-R @PeterJones . As I said before, I am not an expert in notepad++ at all. I’ve done a degree in computer science 15 years ago, but I’m not at all specialized in programming and I’m doing totally different things today. I found all these little tips very interesting and I’m sure they will be very useful in the future. Thanks again to both of you!

    I’ve completely finished the translation, for the rest I’ll only have to touch up the fonts and make corrections that I would have noticed in game.

  • 0 Votes
    6 Posts
    3k Views

    I like the solutions proposed above because they are relatively simple and to-the-point. However, regex-replaces on JSON in general get pretty hairy due to factors including but not limited to:

    how do you differentiate between a pattern in a key versus a string? how do you take into account the fact that JSON doesn’t care about the order of keys whereas regexes do? what if there are ] or } inside strings, such that the regex is fooled into thinking the JSON object ended?

    Just to illustrate how annoying regex-replaces get once you start trying to satisfy all the syntactic requirements of JSON, here’s a regex-replace I came up with to achieve this while ignoring insignificant whitespace and the order of keys and removing any trailing commas:
    find/replace (?-i),\s*{(?:[^{]*{[^}]*}\s*,\s*"model"\s*:\s*"[^"]*KeepInfo[^"]*"\s*|\s*"model"\s*:\s*"[^"]*KeepInfo[^"]*"[^{]*{[^}]*}\s*)}\s*(,)? with \1.

    JsonTools is a fine solution for this, if you’re able to use plugins.

    Because it uses a JSON parser to parse the JSON, it is insensitive to the formatting of the JSON.

    To filter JSON with the plugin, just use Alt-P-J-J (tap the keys in sequence, don’t hold them down simultaneously) to open the tree view, then enter one of the following queries into the query box and hit Ctrl+Enter, then Save query result.
    Two queries that accomplish your goals:
    @[:][not(@.model =~ `(?i)keepinfo`)] filters out objects where the model includes keepinfo ignoring case.
    @[:][not(@.model =~ KeepInfo)] filters out objects where the model includes KeepInfo in that case only.

    While I’m here, PythonScript is also an efficient solution:

    import json from Npp import editor j = json.loads(txt) filtered = [o for o in j if 'KeepInfo' in o['model']] filtered_text = json.dumps(filtered, indent=4) editor.setText(filtered_text)
  • 2 Votes
    3 Posts
    221 Views

    @Alan-Kilborn You’re just awesome dude, thank you very much. Works like a charm.

  • 0 Votes
    2 Posts
    636 Views

    @mkupper ,

    Ugh. Apparently, like backslash-square-brackets, HTML entities are another thing that NodeBB messes up when you edit a post, because it was right when I first posted it. Fixed. (edit: updated the forum-formatting FAQ to call out that oddity with entities, as well)

    Regarding DM: the “chat” feature speech bubble in the upper-right by your icon is the way to do private messages
    d3a7bd64-4296-4f8b-a302-820992061b17-image.png

  • 0 Votes
    8 Posts
    903 Views

    @Chris-Johnston In reading https://www.autoitscript.com/forum/topic/210204-automate-notepad-new-doc-creation-moved/ it appears that in Notepad++ you want

    Settings / Preferences / New Document (on left sidebar) / Default language to be AutoIt.

    Notepad++ can already do that. What Notepad++ does not seem to have baked in at present is a default blank document template. It’s not clear though
    if filling in the new tab with stuff related to a generic .au3 file is useful or essential to you. Any of what people have already suggested here will do for filling in the default new-document but it’s also possible a plugin exists that can do this.

  • Sort lines but keep the hierarchy

    May 15, 2023, 7:57 AM
    0 Votes
    5 Posts
    546 Views

    Hi, @rune-egenes and All,

    Easy !

    First regex :

    SEARCH \R(?=\t)

    REPLACE Leave EMPTY

    Sort

    Second regex

    SEARCH (?=\t)

    REPLACE \r\n    or    \n if you deal with UNIX files

    BR

    guy038