• Find/Replace multiple lines

    2
    1 Votes
    2 Posts
    543 Views
    PeterJonesP

    @Dave-C-1 said in Find/Replace multiple lines:

    Can this be done in one pass?

    Using regular expression search, yes.

    FIND = 2 NOTE GRID=(\d+)
    REPLACE = 2 ADDR $1\r\n$0

    In the FIND, the (\d+) says "find one or more digits and put in group#1)
    In the REPLACE, the $1 says “use the contents stored in group#1” and the $0 says “use the full matched text”

    ----

    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
  • REGEX: Combine the two lines on a single line

    9
    0 Votes
    9 Posts
    811 Views
    Hellena CrainicuH

    @Mark-Olson said in REGEX: Combine the two lines on a single line:

    FIND: (?s-i)(?:<meta[^<>]*content\s*=\s*"|(?!\A)\G)[^"]*?\K\R
    REPLACE BY: (leave empty)

    super. thanks

  • Regex: Find Pages with One String but Not Another

    18
    0 Votes
    18 Posts
    3k Views
    Mark OlsonM

    @guy038
    Looks good! I’d amend it to (?s-i)\A(?=.*(?:Bob|Peter|John))(*COMMIT)(*FAIL)|Mary|Helen|Alice, as this ensures that the check for the forbidden names is only done once at the beginning of the file, and thereby avoids the issue of bad performance on very large files.

  • find "value": "word or two or three" replace with "value": "?"

    3
    0 Votes
    3 Posts
    651 Views
    isntworkdullI

    @PeterJones said in find "value": "word or two or three" replace with "value": "?":

    “value”: “[^”\r\n]*"

    perfect - I would never have got to that!!

    thank you

  • Auto Complete feature is not working properly

    15
    1 Votes
    15 Posts
    2k Views
    TuiSilvaT

    @PeterJones said in Auto Complete feature is not working properly:

    Nope. This Forum is about Notepad++, not a generic help forum for programming.

    OK, thanks for letting me know :)

  • using search-replace possibly with wildcards?

    3
    0 Votes
    3 Posts
    628 Views
    Volker MennekingV

    @PeterJones said in using search-replace possibly with wildcards?:

    Template for Search/Replace Questions

    Thank you very much. It funkt.

  • [NppFTP] Cannot start FTP session

    6
    0 Votes
    6 Posts
    454 Views
    Volker MennekingV

    Thank you for this detailed answer. Actually I just needed the correct download link. Sorry, I probably should have asked the question more precisely. The fact is: with release v30.17 Notepad++ works again. Merry Christmas and a Happy New Year

  • Bookmark line becomes unchecked on reopening application

    7
    0 Votes
    7 Posts
    2k Views
    Alan KilbornA

    @Alan-Kilborn said in Bookmark line becomes unchecked on reopening application:

    not sure why this text seems to have a Alt+h keyboard accelerator as I don’t see how you can use it in Notepad++'s UI.

    One more thing I’m not sure of: Why I had said that.
    If a control in the Incremental Search window has input focus, e.g. the Find edit box, then Alt+h will focus and toggle the Highlight all checkbox setting.

  • How do I delete only the second line from multiple text files?

    2
    0 Votes
    2 Posts
    191 Views
    Alan KilbornA

    @한승호

    Find: (?-s)\A.*\R\K.*\R
    Replace: nothing
    Search mode: Regular expression
    Action: Replace-in-Files

  • Bulk Editing Values in XML Files

    4
    1 Votes
    4 Posts
    2k Views
    A

    @Coises

    This is exactly what I was hoping for. Python is well and good, but I haven’t dived into it for good reason. Thanks for letting me know this exists ^.^

  • JSON tools for viewing and editing

    4
    1 Votes
    4 Posts
    99k Views
    Mark OlsonM

    @Austin-Gilliam
    It looks to me like your JSON is a JSON string representation of a JSON array. This means that the parse() RemesPath function (follow that link, then find the parse() function) will help you. It attempts to parse a JSON string, and returns an object that either has result: (the result of parsing) or error: (the error that caused parsing to fail). Note that this function was added in a pretty recent version (v5.5.0), so you might want to get the latest version if that query fails.

    Here’s an image of what we get with your JSON.

    1191f8b3-c9b2-4d98-b544-5511e06b6143-image.png

    As you can see from the treeview on the right, the parse() function worked. Since we know it’s successful, I’ll just change the query slightly, to parse(@).result (which extracts the result value). Now I just click the Save query result button above the tree, and the parsed array is saved in a new buffer. The contents of this buffer will be as follows:

    { "FastenerData": { "508670": {"Item1": "10", "Item2": "50"}, "508674": {"Item1": "10", "Item2": "50"} } }

    By the way, I’m the maintainer of JsonTools, and you can always raise an issue in the repo (linked here) if you need help. But this is a fine place to do it as well.

    @PeterJones
    I’m pleased to see that you noticed the potential of Dump JSON string(s) as raw text in this situation. I was just about to mention it, but I saw you beat me to the punch.

  • batch changing png image to same as filename

    8
    1 Votes
    8 Posts
    600 Views
    Terry RT

    @Coises
    I like it, only issue is you forgot to return the .png in the replacement field. That is unless you meant for the Find What to use a lookahead?

    Just goes to show that although regex can’t count it can be made to do some wonderous things nobody would have believed if they didn’t see it for themselves.

    Terry

  • 1 Votes
    12 Posts
    1k Views
    2

    @mkupper

    Well Tank you very much for the time you have spent on it.
    It was an analysis which I myself did not think of it.

    I don’t have much knowledge in this field maybe browsers or web pages like this use Woff or something like that.

    By the way TYSM.

  • Show/hide the toolbar

    2
    1 Votes
    2 Posts
    2k Views
    Michael VincentM

    @mkupper said in Show/hide the toolbar:

    I have PythonScript 2 installed and so if toggling the toolbar state between hidden and standard is possible then some example code would be great.

    Easy enough:

    notepad.hideToolBar(True)

    To unhide, just pass False instead.

    Cheers.

  • 1 Votes
    2 Posts
    438 Views
    Terry RT

    @Ed-Klein said in If I have multiple desktops active can there be an open Notepad++ window on each:

    Is there a way to start an additional session in each desktop

    There are a number of methods which might help, I will explain them but I haven’t given you all the solution, you will need to complete that yourself based on which idea you decide on.

    Multi-instance mode. That comes with a caveat, last session to close will generally be the one to write the persistent version of config data ready for the next time. So for example if you say you set Dark Mode enabled (Preferences, Dark Mode) and that session is the last to close, then the next time Notepad++ starts Dark Mode will be enabled, even if the other sessions previously did not have it enabled.

    Notepad++ allows for a commandline setting to determine where on the displays it will appear. These are -x and -y settings for the upper left corner of Notepad++. See the online manual here.

    There is also another commandline setting that might alleviate any issues with using multi-session, -settingsDir. So you could elect to have multiple settings directories, one for each monitor/desktop. Each directory would contain all the config files that appear in the normal folder %appdata%\Notepad++. So with this method you would not need to set the x and y coords, rather with multi-instance enabled and using the settingsDir you would open Notepad++, move each instance to the required desktop and then close. On the next opening, the Notepad++ window would appear in the correct monitor. So each shortcut would need to refer to the correct alternate settingsDir

    You could install multiple “Portable Notepad++” installations. In this case updating them is more of a pain since that will overwrite all the config data in each portable installation. Details are here

    I suggest reading up on each, run some tests at the commandline to see which might best help you, then set about creating the right shortcuts to aid in running the preferred method.

    Terry

  • Issues with copy/paste on v8.6

    8
    1 Votes
    8 Posts
    5k Views
    Alan KilbornA

    @mkupper said in Issues with copy/paste on v8.6:

    If you have been used to holding the Ctrl key down in preparation for a Ctrl+C or Ctrl-V then I suspect it’s very difficult to unlearn it.

    When new features are added to software, you have to learn how to use them. Sometimes that involves some unlearning, and yes, that may be difficult. But, in theory, at the end, you are in a better place.

    But with all the bugs with this new feature, we are seemingly far from that “better place”. Hopefully it can all be sorted out and fixed (multi-select mode coexisting alongside column-block-select mode), and hopefully the N++ developer has interest in doing so.

  • "Autohide tabs bar if one document opened"

    6
    0 Votes
    6 Posts
    390 Views
    Alan KilbornA

    Have you tried the script solution that was presented HERE?

    Just noting this: There’s also the case of two views to consider. I suppose if both views were open, that counts as a multiple tab situation, so the tab bar would have to be shown.

  • Convert multiline data to CSV - Regex not working

    9
    1 Votes
    9 Posts
    1k Views
    S

    Thank you to everyone for their input, lots of things to try and I’ll certainly be taking a look at the Json plugin as well.

    Coises comment here in particular kicked me into the right way of thinking…

    @Coises said in Convert multiline data to CSV - Regex not working:

    @Schmill said in Convert multiline data to CSV - Regex not working:

    I’m assuming that the Regex is evaluating the first line, running the replace (which now places line 2 as an append to line 1), but now considers that line 1 is “done”, and moves onto line 2 (which is the old line 3 before the replace joined lines 1 and 2).

    It’s not that (the new) line 1 is done; it’s that the beginning of the old line 2 is no longer the beginning of line, so the ^ doesn’t match.

    Changing my “Find What” to be:
    (.+)\R
    and my replace to be:
    “\1”,

    Means that everything is converted as expected - I had overcooked my regex!

    Many thanks again all!

  • Regex: Find html tags that only contain numbers

    4
    0 Votes
    4 Posts
    480 Views
    Hellena CrainicuH

    I believe I find the solution:

    FIND: <[^>]*>(\d+(\.\d+)?(\s*\w*)*)<\/[^>]*>

  • Opening .cfg by default with Notepad++

    7
    1 Votes
    7 Posts
    6k Views
    CoisesC

    @Julian said in Opening .cfg by default with Notepad++:

    @Coises It opens in normal Notepad when I double-click at the moment.

    If you’re familiar with the registry editor, take a look at HKEY_CLASSES_ROOT\.cfg and see what is there.

    If it has a single value, Default, which reads cfg_auto_file, take a look at HKEY_CLASSES_ROOT\cfg_auto_file.

    If one of those has a shell\open\command pointing to notepad.exe, you could try changing it to the path to Notepad++. No warranties, express or implied, about what happens if you change things in the registry, though… I mean that.