• Replace based on input CSV file

    2
    0 Votes
    2 Posts
    543 Views
    Alan KilbornA

    @Willem-Swanepoel

    You would likely need to use a scripting plugin for such replacement. Maybe search this forum for “replace from list” or something similar.

    For example, THIS appears to be a script that solves a problem similar to your need, although not exactly.

    Sometimes a regular expression replacement operation can do it, by combining your data and your list together in a single file tab, but this method may not be reliable on larger data sets.

  • one corner case where npp doesn't warn about "{file} doesn't exist anymore"

    13
    0 Votes
    13 Posts
    1k Views
    Neil SchipperN

    @Pierre-McGrail I was able to replicate OP’s issue with npp.8.4.9.portable.x64, so the option you mention, while very helpful in many situations, does not eliminate the problem.

  • How to remove duplicates words?

    12
    1 Votes
    12 Posts
    4k Views
    guy038G

    Hello, @alan-kilborn and All,

    I’ve found out an interesting thing about posts which contains a literal [ character in search regexes :

    \\[

    If you must edit one of these posts in order to change any other part, you’ll need to repeat the special modifications, regarding the regexes, by using, again, the syntax :

    \\\[

    BR

    guy038

  • Remove right side white bar in npp 8.4.9

    4
    0 Votes
    4 Posts
    304 Views
    Alan KilbornA

    @Debajyoti-Datta said in Remove right side white bar in npp 8.4.9:

    npp highlighter plugin, which I don’t remember if that came default with npp 8.4.9 first time.

    It did NOT. The only plugins that ship with Notepad++ currently are:

    mimeTools NppConverter NppExport
  • Is there a way to make notepad++ faster ?

    4
    0 Votes
    4 Posts
    1k Views
    Mark OlsonM

    @Mark-Olson
    The find/replace feature has been implemented in HugeFiles. No formal benchmarking, but was able to perform a find/replace operation with over 50,000 changes on a 200MB file in about 3 seconds. Your mileage may vary, and I haven’t yet tested it on anything bigger than that.

  • Line combination

    13
    0 Votes
    13 Posts
    1k Views
    PeterJonesP

    @Mark-Olson ,

    Why not just … ?

    In this specific instance? Because it shares the same problem as \R in this instance: if your real text is "\r\n, then (?<!")(?:\r?\n|\r) will match between the \r and the \n in the file.

    In general? Because in the vast majority of plaintext files, everything it matches is also matched by \R, which is so much easier to type.

  • target links

    2
    0 Votes
    2 Posts
    373 Views
    PeterJonesP

    @Lhuillier-Sébastien ,

    You say you can do the replacement – which means you aren’t asking about the replacement. (unless there’s a language barrier which has caused a mis-translation between you and me)

    And other than having a target attribute in the link example you showed, you haven’t actually asked anything about “target links”, despite that being the title of your question.

    So I’m not sure then what your question is about.

    ----

    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.
  • Replacing 5-digit numbers in lines that start with specific characters

    2
    0 Votes
    2 Posts
    698 Views
    PeterJonesP

    @FurBlood-Abe ,

    Thank you for the example data, but it would have also been nice to explain what you wanted in words.

    I have interpreted your request as “How do I replace any line like <Y>#####</Y> with <Y>27245</Y>, where ##### can be any 5-digit number?”.

    Answer:

    FIND = <Y>\d{5}</Y> REPLACE = <Y>27245</Y> SEARCH MODE = Regular Expression

    ----

    Useful References Notepad++ Online User Manual: Searching/Regex FAQ: Where to find other regular expressions (regex) documentation
  • Maximum number of windows can be opened in one notepad++

    4
    1 Votes
    4 Posts
    6k Views
    PeterJonesP

    @Dziekan-TEK ,

    You are replying to a thread that’s 7 years old. Claudia hasn’t been here in years (unfortunately so: she was one of the most-helpful users that I’ve ever seen on this site, and her input has been missed since she left).

    If you want to search 3000 files, you don’t have to open them all and “Find All in All Opened Documents”. The “Find in Files” feature will work much better for that: it will search a directory (recursively, if you want), and list all the files that have matches, without having to have them all actually open in Notepad++ at the same time. That seems like the ideal solution. (I don’t remember whether Find in Files existed in 2016 or not.)

  • Help wanted for translate of part text

    4
    0 Votes
    4 Posts
    347 Views
    Alan KilbornA

    @daf-de-sade

    Although it goes “off-topic” for this forum, perhaps having a look at the postings in THIS THREAD would be of assistance to you, especially the ones that are February 2.

  • 0 Votes
    19 Posts
    1k Views
    Alan KilbornA

    @blueicehaller

    Notepad++ provides the “Explorer Plugin” with “Favorites” or “Project” with 3 “Project panels”.

    To be correct:

    the “Explorer Plugin” provides “Favorites” Notepad++ itself provides “Project” with 3 “Project panels”

    When using “Favorites” how can I add a file from [Sessions] to [Files] with drag & drop?

    Explorer doesn’t seem to have “drop target” functionality, so you aren’t going to be able to do this.

    You could make a feature request of the Explorer plugin author for this.

    When using “Project Panel 1” and trying to add open files with drag & drop to a Project the file has not been added.

    Notepad++ itself doesn’t seem to have drop functionality for a project’s / workspace’s files.

    You could make a feature request for this.

    When I have “Favorites” and “Project Panel 1” open and restart Notepad++ “Project Panel 1” is always in focus instead of “Favorites”.

    How can I change that behavior?

    If they are in the same docking panel, which it sounds like they are, then probably the one that is the right-most tab will be the one that N++ actives on its startup?

    Hmm, no I tested that theory and a project panel (Project 1) moved to the far right and became active after the next N++ restart.

    Another theory would be that the Explorer plugin panel tabs (I have 2 active, the “explorer” one and the “favorites” one) would always be adjacent as one would think they would be created as the plugin loads. But no, experimentation for me shows I get, left-to-right, “explorer”, another plugin’s panel tab, and then “favorites” (and then “project 1” as I mentioned).

    Bottom line is I’m not sure how the ordering of tabs in a panel is “restored” from a previous run of N++ when it restarts, except to say that restoration order doesn’t appear to be ideal…

  • 3 Votes
    3 Posts
    4k Views
    Casper AbrahamC

    Tried all kinds of things and eventually it was THIS problem. Great insight into why this happens all of a sudden. Old maybe but still relevant.

  • Delete lines with PythonScript

    3
    0 Votes
    3 Posts
    677 Views
    Brian HigdonB

    @Alan-Kilborn Thank you for getting back to me so quickly.

    Yes, you are correct on my regex string. Adding \R did what I needed it to do.

    editor.rereplace(r’^.: “”.$\R’, ‘’)

    You are not confused; I confusingly wrote my question.

    The issue is solved.
    Thank you.

  • Pinpoint what I did and want to see on a taskbar

    3
    0 Votes
    3 Posts
    302 Views
    Su KimS

    @PeterJones
    Many thanks to your quick answer and I appreciate your comment.

  • Deleting a string and the surrounding code.

    6
    0 Votes
    6 Posts
    755 Views
    PeterJonesP

    @Usman-Isa ,

    Your example data isn’t as complicated as what you’ve described earlier – it doesn’t have any of the “sometimes” that you kept mentioning – but it’s also got new features (indentation) that weren’t there before. So I virtually guarantee that after you try this, you will come back and say “it doesn’t work” – and it’s because you haven’t shown representative data. As the FAQ that you “read” to be able to quote the syntax made very clear: to get a good answer, you need to provide multiple examples, of things that will and won’t be transformed. Once again here, you just showed one example. So it’s not going to 100% meet your needs. And you are going to have to live with the consequences of your decision to provide insufficient data.

    But pretending that what you said in your most recent post is literally what you meant:

    FIND = (?-s)^.*\R.*(/AISC-SPEC/).*\R^.*\R
    REPLACE = $1
    SEARCH MODE = Regular Expression

    This will look for a group of three lines, where the second line contains whatever is in between the parentheses in the regex; it will replace those three lines with just the text that was stored in the regex parentheses.

    If you decide that this isn’t sufficient, you are going to have to put more effort into your request. Good luck.

  • Notepad++ 7.7.1 won't default to .txt when saving

    15
    0 Votes
    15 Posts
    6k Views
    EkopalypseE

    @Viri-Davu said in Notepad++ 7.7.1 won’t default to .txt when saving:

    … and in fact, Notepad++ is based on Windows Notepad, …

    I’m curious, what makes you think this is the case?

    @Viri-Davu said in Notepad++ 7.7.1 won't default to .txt when saving:

    Even for security reasons it should be. …

    Can you explain this in more detail? Why should files be saved as .txt for security reasons? This does not make sense to me. Where is this specified?

  • Script for automatic insertion of modified rows

    8
    0 Votes
    8 Posts
    373 Views
    guy038G

    Hello, @martin-steiner, @ekopalypse and All,

    Of course, the @ekopalypse’s python script seems the best bet ! However, you can just achieve it with the native regex engine of N++ !

    I was able to download your Test_File.zip archive and extract the Cooper_CH1_Call.xml file

    Just execute each point of the method below :

    Open your Cooper_CH1_Call.xml file in N++

    Open the Mark dialog ( Ctrl + M )

    Uncheck all the box options

    Check the Wrap around option

    SEARCH (?x-si) (?<= <Text> ) .+ (?= </Text> )

    Select the Regular expression search mode

    Click on the Mark All button

    Click on the Copy Marked Text button

    Move to the very end of the file

    Add an empty new line

    Paste the bookmarked lines with Ctrl + V

    => Near the end of the XMl file, you should get this text :

    </DialogCues> <Name>Cooper_CH1_Call</Name> </DialogCueSheetData> Ahoj. Tady je opět Cooper. You cannot open that door \nwith your current version of \nthe OMNI View software. You will need to update your \nsoftware at a Daemon server. Upgrade to version 1.0 and \nyou can open this door. Then, you can get the girl to the Library. Nejbližší Daemon se nachází v jídelně, na druhé straně kolejí. I will add this waypoint to your OMNI View. I will also highlight this location on your map. I will add this waypoint to your map. ... ... ... Zobrazíš ji výběrem ikony mapy v telefonu. Buď opatrný. The girl must feel a strong sense of deja vu, but fortunately you have been down this road before, too. Each confinement room contains a power unit in case of power failure. Find the unit to open the door. It is in a different location inside every room, so check every corner in OMNI-View. Tohle je pepřový sprej značky P-Zero. Equip it with the phone, and select a guard for her to attack. Knowing the girl, she'll defend herself even without the spray equipped. But be careful, each canister has a single shot. And guards will eventually return to patrol angrier than ever.

    Note that I assume that your initial XML file does not contain any empty line !

    Now, simply add the desired translation of every line, after some space characters. For instance :

    </DialogCues> <Name>Cooper_CH1_Call</Name> </DialogCueSheetData> Ahoj. Tady je opět Cooper. Line 001 You cannot open that door \nwith your current version of \nthe OMNI View software. Line 002 You will need to update your \nsoftware at a Daemon server. Line 003 Upgrade to version 1.0 and \nyou can open this door. Line 004 Then, you can get the girl to the Library. Line 005 Nejbližší Daemon se nachází v jídelně, Line 006 na druhé straně kolejí. Line 007 I will add this waypoint to your OMNI View. Line 008 I will also highlight this location on your map. Line 009 I will add this waypoint to your map. Line 010 ... ... ... Zobrazíš ji výběrem ikony mapy v telefonu. Buď opatrný. Line 244 The girl must feel a strong sense of deja vu, but fortunately you have been down this road before, too. Line 245 Each confinement room contains a power unit in case of power failure. Line 246 Find the unit to open the door. Line 247 It is in a different location inside every room, so check every corner in OMNI-View. Line 248 Tohle je pepřový sprej značky P-Zero. Line 249 Equip it with the phone, and select a guard for her to attack. Line 250 Knowing the girl, she'll defend herself even without the spray equipped. Line 251 But be careful, each canister has a single shot. Line 252 And guards will eventually return to patrol angrier than ever. Line 253

    Then :

    Open the Replace dialog Ctrl + H

    Uncheck all the box options

    Check the Wrap around option

    SEARCH (?x-si) (?<= <Text> ) ( .+ ) (?= </Text> (?s: .+ ) ^ \R (?-s: .+ \R )* \1 \x20{2,} ( .+ ) ) | (?s) ^ \R .+

    REPLACE ?2\2

    Select the Regular expression search mode

    Click on the Replace All button

    Here you are ! All the lines <Text>..........</Text> should now contain their corresponding translation Line ### !

    Best Regards

    guy038

    P.S. :

    In case, your XML file contains empty lines, change, for instance, the uniq empty separation line with a line of @ characters and use the regex replacement :

    SEARCH (?x-si) (?<= <Text> ) ( .+ ) (?= </Text> (?s: .+ ) ^ @+ \R (?-s: .+ \R )* \1 \x20{2,} ( .+ ) ) | (?s) ^ @+ \R .+

    REPLACE ?2\2

  • Setting UDL for file names

    3
    0 Votes
    3 Posts
    206 Views
    dipaolovD

    @Ekopalypse Thanks!

  • how delete all text before word?

    2
    0 Votes
    2 Posts
    220 Views
  • User defined language and break/extra return statements

    4
    0 Votes
    4 Posts
    483 Views
    Lycan ThropeL

    @Charles-Chickering ,

    The problem here, is like Peter has mentioned. The UDL is a general parser, which makes it kind of dumb, but it does it’s job. The problem may be that you might need to rewrite your code if it’s able to be done.

    I found this problem in our UDL also, and rewrote the code instead, to reflect a better practice.

    For instance, if your language allows it, using a return in an if/endif conditional is essentially a “goto” escape clause reminiscent of early Basic. It was frowned on then as well, but did the job. If your condition in that code is accurate, then presumably you are accessing variables that you’re allowed to change in the function that is being passed to it, or it’s able to change the variable directly. If that is the case, perhaps you should just do the variable change which is the purpose of that conditional controlling.

    For instance, in that example code, Function foo is called, and the first thing it does is check if the A == 1. If it is, goes to the next if, if not, it goes to the end of A before the code before the return statement. If it does equal A, it then goes to the next conditional check if B==0, which if it is, it changes the variable x to 2. IF B is not equal to 0, it will automatically go to the else statement and change C to 3. No need for a return statement here. Your 2 if statements will end.

    Unfortunately, the way your code shows above, the return only keeps the code from continuing after x is changed to 2, where you’re trying to exit the function at that point. That’s not what you should be doing. You should be letting the function finish it’s run so it can return on it’s own.

    If the code at the end is not to be run, if the above conditions are met, then you need to add an else condition for if A<> 1, like this:

    function foo() //Simplified code if (A == 1) if (B == 0) x = 2 else C = 3 end //end b else //more code that doesn't execute if above condition is met end //end a return

    Follow the logic. those conditions have to be met. If they are met, they ignore the rest until they reach the end of the function, if you have structured them properly. At that point, you don’t need the return statement acting like a “goto” statement.

    The only other option, but the above code doesn’t seem to follow logically and it could just be junk code you provided, but a function usually returns a value, whether it is typically a 0 for success, 1 or -1 for fail (or vice versa if you have changed the return values), or a value that was computed. That’s how a return is supposed to work…so if I was writing code like that, it would return a value and that value is what you would return. For instance:

    function foo() //Simplified code if (A == 1) if (B == 0) x = 2 returnVal = x else C = 3 returnVal = C end //end else //more code that doesn't execute if above condition is met return returnVal end //end a return returnVal

    In this way, you’re returning a value, that can be interpreted at the point after the function returns. The above actually kind of looks like how a function might be overloaded to return different values depending on the code. I feel it should return one value type, not different ways depending on different variable values.

    Doing either of these two ways, would be programmitically consistent and proper, and void the issue of your folding not working properly.