• 0 Votes
    2 Posts
    522 Views
    Terry RT

    @freshenstein said in Delete everything after the twelth character in a line with other lines of text that need to be left alone:

    Is there a way to add to this code that tells it to only look for lines that start with “thing”+number and then delete everything after 12 characters?

    Possibly as long as the number is a consistent length, you would change your formula to something like ^(thing \d{6}). Doing it this way you need to limit to an exact character count, so the number must ALWAYS be 6 characters long.

    Alternatively something like ^(thing \d+) will work. So it works up until the end of the number. This could be 12 characters, or more or less. The \d+ means as many digits that are together, but must be at least 1.

    Terry

    PS understand I’m only editing the first part of your regular expression. It’s up to you to add in the “rest of the line” or whatever else you intend to do.

  • 0 Votes
    3 Posts
    354 Views
    Long-Manith SREYL

    @guy038
    Thank you so much*It’s perfect :)

  • 0 Votes
    17 Posts
    1k Views
    guy038G

    Hello, @alimirzaei5778, @neil-schipper, @terry-r, @alan-kilborn and All,

    We can even speed up the search regex process with this syntax :

    (?-is)^sunday.+\R.+\R(?:(?! 1112).+\R){4,}A=.+\R?

    Indeed, if several consecutive blocks, without the string \x201112 at beginning of lines , it will select all these blocks, in one go !

    You could say why does it work that way ? Well, the regex part (?:(?! 1112).+\R){4,} finds any consecutive range of lines which do not begin with \x201112

    And it’s particularly the case of the lines :

    Beginning with Sunday

    Beginning with Int

    Beginning with A=

    Luckily, this accumulation of matched lines stops as soon at it meets a line beginning with \x201112. But, as it must also satisfy the end of the regex A=.+\R?, the regex engine is forced to backtrack 3 lines before ( by decreasing the quantifier of 3 ( one at a time ), in order to match the last line of the previous block, beginning with A= !

    Best Regards,

    guy038

  • "Scroll" current line to the top of the screen

    12
    0 Votes
    12 Posts
    1k Views
    P CooperP

    @alan-kilborn Perfect. Thanks ever so much!

  • How to CENTER TEXT?????

    15
    0 Votes
    15 Posts
    18k Views
    Shridhar KumarS

    The response to the OP should have been “Center to what?”. The number of characters in a line in Notepad++ has practically a very high limit. As such there can be no concept of centering to a frame or a page.

    If the OP meant to have the text centered when the file was printed, then that is something different, and probably a desirable feature to have even in a text editor.

    Funny story. Shortly after I had released my GotoLineCol plugin, the first two issues I received were that the Column Position (either by Character or Byte) field in the plugin side panel had a limit of only 5-digits! See here: Issue #1, Issue #2.

    I couldn’t have anticipated that people were dealing with files having lines longer than 99,999 characters. To resolve the issues, I increased the field length in the plugin panel to allow up to 8 digits. The fix took only a few minutes. But to test it, I had to prepare a file with at least a single line having more than 350,000 characters. This part took me significantly longer time.

  • Remove strings every nth space

    3
    0 Votes
    3 Posts
    212 Views
    JessicaWills837J

    @terry-r This was very helpful, and worked perfectly. I was able to use and also modify your solution to remove the ending time aswell. Really cool the stuff you can do with N++

  • how to extract?

    7
    0 Votes
    7 Posts
    333 Views
    Neil SchipperN

    @zarate-petery

    As a starting point, this regex matches all complete lines that do contain PACKS_1: ^.*?PACKS_1.*?$\R

    You can use it in a Replace All operation with Replace field completely empty; this would delete all these lines.

    This would meet the overall need with your sample data, but possibly not all of your real world data.

  • Find & Replace sets of value with an unique of values

    5
    0 Votes
    5 Posts
    515 Views
    Luigi Giuseppe De FranceschiL

    @alan-kilborn no problem :)

    i applied a brute force approach and now i hope my xml will work:

    step 1) find <relationship and replace with <relationship>FYY ( *
    step 2) find source and replace with ) source *
    Step 3) find (?-s)(?-i:<relationship>|(?!\A)\G).?\K(?:\x20(.+?)) with identifier=“id-999999”
    Step 4) find >FYY and replace with " "
    Step 5) find <connection and replace with <connection>FYY
    Step 6) find relationshipRef and replace with ( relationshipRef
    Step 7) find (?-s)(?-i:<connection>|(?!\A)\G).?\K(?:\x20(.+?)) and replace with relationshipRef=“id-999999”
    Step 8) find >FYY and replace with " "
    Step 9) find ) source and replace with source

    am i mad? :D

  • Replace sets of numbers in a given position with 0

    4
    0 Votes
    4 Posts
    270 Views
    Fernando BernabeuF

    @neil-schipper
    Thank you very much! That worked wonderfully!

  • Add the same amount to every selected value?

    23
    0 Votes
    23 Posts
    3k Views
    guy038G

    Hello, @diz-hydron and All,

    Well, @diz-hydron, I suppose you could begin with this very simple script, named diz.py

    def player_1(m): return str(int(m.group(1)) + X1) + ', ' + str(int(m.group(2)) + Y1) def player_2(m): return str(int(m.group(1)) + X2) + ', ' + str(int(m.group(2)) + Y2) editor.rereplace('"player1": \\[\K(-?[0-9]+), (-?[0-9]+)', player_1); editor.rereplace('"player2": \\[\K(-?[0-9]+), (-?[0-9]+)', player_2);

    Before running the script, of course, change the X1, Y1, X2 and Y2 values for true positive or negative integers ( e.g. +7 or -3 )

    It should work nicely with your text posted here

    In a next step, it would be better to enter the different values with, for instance, the notepad.prompt python command and assign the 4 typed numbers to the X1, X1, X2 and Y2 variables…

    Best Regards,

    guy038

  • Get back MS NOTEPAD

    3
    0 Votes
    3 Posts
    269 Views
    PeterJonesP

    @dave-venus ,

    If you mean “When I double-click a .txt file, it opens with Notepad++ instead of MS Notepad”, then that does automatically happen when you install Notepad++. To undo it, use your Windows Operating System’s method of changing your file association – probably easiest is to right click on the .txt file, Open With, choose MS Notepad, and check “always open this type” or however it’s phrased in your exact version of Windows. (Note, these instructions aren’t unique to Notepad++ – any time you install a new file editor, it almost always changes the default association for one or more types of files, and if you don’t want that behavior, Open With is the way to re-associate it with your previous application.)

    However, if, like @Lycan-Thrope assumed, you try to run notepad.exe directly (double-click on the executable, or use the Windows Run dialog and type notepad.exe) and it instead runs Notepad++, then you have done something odd at some point: probably, either you intentionally used the notepad replacement instructions – in which case you need to undo those – or you installed the “NotepadStarterPlugin”, in which case you need to follow the “Uninstallation” instructions on that plugin’s page.

  • By regular expressions

    2
    0 Votes
    2 Posts
    195 Views
    Neil SchipperN

    @yuliya-drimmer I don’t think a general solution where you specify the number of after-lines is possible.

    As you may know, a regex that matches a word and then removes line separators for a specific number of after-lines is possible. Hence, if the range of required after-lines is not too big, a family of regexes that supports the overall need could be made.

  • Replacing a number with line number in text

    2
    0 Votes
    2 Posts
    760 Views
    Neil SchipperN

    @yosef-ymj Hi. I suggest you learn to use Edit -> Column Editor (Alt+c) to insert a column of ascending numbers.

    Then, learn to use Alt+MouseMovement to select rectangles, and gain skill with rectangular cut/copy/paste operations.

    When working with rectangles, these are also helpful:

    Shift+Alt+ArrowKey to adjust dimension Shift+Alt+LeftMouseClick to specify opposite corner of a rectangle whose other corner is current caret position

    If your data is as uniform as shown, a sequence using the above operations will do what you want, although you may need to handle 1, 2 and 3 digit sections separately.

    To review some creative solutions to rectangular text problems, use the magnifier icon and search this site for terms like “column editor rectangle paste”.

    Drop a follow-up comment to indicate whether you succeeded.

  • Dark Mode Switch

    2
    0 Votes
    2 Posts
    401 Views
  • removing characters

    4
    0 Votes
    4 Posts
    249 Views
    Robert CarnegieR

    @kracovwolf I think you will want to use “Search Replace” with “Search Mode” of “Regular Expression”.

    This is a very complicated option, but what you specifically need to do is simple:

    ^J
    means “J at the start of a line” in Regular Expression language. You can replace this with nothing. From your example, you should replace “J space” which is also there.

    It will not remove the start of line. It will only remove J or remove J space.

    J$
    means “J at the end of a line”.

    Doing one and then the other is simplest.

    It will still be your responsibility to not remove more J s than you want to.

  • Win11 pinned taskbar icon middle click = new document

    4
    0 Votes
    4 Posts
    575 Views
    Robert CarnegieR

    @martin-olsson This is a possible candidate for using a third-party “macro” program to create specific behaviour on your computer. I use a downloaded tool called “AutoHotkey” but I haven’t created with it recently.

    As far as I remember, things that an AutoHotkey macro can do include:
    Read the title bar of a program
    Bring a program (Notepad++) to foreground and out of being minimized
    Send a keystroke to a program (Ctrl N new document)

    So you could have an icon on your screen that does all of that from one click.

    Other options are possible, such as always waiting for YOU to foreground Notepad++ and THEN send Ctrl N each time, or, to see if the title bar says “new” for a newly created document already.

    Or it could just make your middle mouse button send Ctrl N.

  • Find & Replace LF not working across whole document

    8
    0 Votes
    8 Posts
    2k Views
    Robert CarnegieR

    @by-eck I’m late to this, but I wonder if Notepad++ is the right tool for this job. If you have to do it more than once - a simple automatic text editor like “sed” would be more suitable.

    It also resembles work I’ve had to do to copy database data to a format that pastes into Microsoft Excel out of “SQL Server Management Studio”. In that case, I wrote a fairly simple SQL user-defined function, whose output is what I want Excel to receive, starting with changing ‘01’ to =“01” so that Excel displays 01 instead of the number 1 - but also removing in-data line breaks and tabs and anything else that annoyed me. Oh, I think it fixes dates. So the output of the data process didn’t contain those hiccups.

    I did that as paid work so I guess my employer owns it, but they may agree to sharing it with the world. Would you like me to ask?

  • Plus to the right of tabs = new tab

    12
    1 Votes
    12 Posts
    2k Views
    rddimR

    The current state is:

    Double click on “blank” area - open new tab Wheel click on tab - close the tab

    What about if we have selectable options for double and wheel clicks?

    For example:

    Double click on blank area and/or tab: Open new tab Close the tab (it is already available in the preferences) Wheel click on blank area and/or tab: Open new tab Close the tab (already available but not configurable)

    The current possible actions are - double click for new tab/close current and wheel click for close.
    The new will be to choose what double click and wheel can do.
    Also will be good if the user can open new tab next to the current when double/wheel click on the current one.

    By the way in the Document List double click works only to open new document, but not to close it. Wheel click also does not work.

    PS: I don’t like the idea to have [+] button because there is already a button for new tab

  • Pinning/Locking a Tab

    13
    2 Votes
    13 Posts
    14k Views
    PeterJonesP

    @alan-kilborn ,

    Sometimes, I do have a sharp wit.

  • Regex: Add html tags in the lines that doesn't have html tags

    12
    0 Votes
    12 Posts
    2k Views
    Robin CruiseR

    @guy038 said in Regex: Add html tags in the lines that doesn't have html tags:

    SEARCH (?s-i)^.+<!-- ARTICOL START -->\R|<!-- ARTICOL FINAL -->.+|(?-s)^(<p class="mb-40px">)?(?|(.+)(</p>)|(.+))$
    REPLACE ?2(?1:<p class="mb-40px">)$0(?3:</p>):$0

    great answer, thank you @guy038