• Inserting g code using replace

    5
    0 Votes
    5 Posts
    984 Views
    guy038G

    Hi, @crafty-crafty, @ekopalypse, and All,

    From the @ekopalypse macro solution, here is an similar solution which can be generalized to :

    Any number of lines which are to be replaced, in the limit of 2,048 characters

    Any number of lines which are to be inserted, during the replacement

    But, first, let’s suppose that you simply have a specific line, repeated many times in your file, which must be replaced with a specific block of lines. Assuming that this line is named #Line# :

    Open a new tab ( Ctrl+ N )

    Type in the specific line #Line# line, followed with a line-break

    Select the entire line #Line#, with its line-break

    Open the Find dialog ( CTRL + F )

    Select, if necessary, the Normal search mode

    Leave all the other options unchecked

    Click on the Find Next button ( Of course, no other occurrence is found, but it does not matter ! )

    Close the Find dialog ( Esc )

    Run the option Macro > Start Recording

    Hit the F3 key ( Whatever an occurrence is found, or not, does not matter ! )

    Hit the Ctrl + V shortcut ( The present contents of clipboard do not matter, too ! )

    Run the option Macro > Stop Recording

    Then, run the option Macro > Save Currently Recorded Macro...

    Type in Replace Next Occurrence with Clipboard Contents, in the Name zone

    Preferably, create a shortcut for this macro

    Click on the OK button to valid the dialog

    Create or select the block of lines, in any file, which must replace the #Line# line

    Copy this block of lines in the clipboard ( Ctrl + C )

    Now, open or select your specific file

    If necessary, move to the very beginning of file ( Ctrl + Home )

    Run the option Macro > Run a Macro Multiple Times...

    Select the Replace Next Occurrence with Clipboard Contents macro

    Tick the Run until the end of file option

    Click on the Run button

    Voila ;-))

    Remark :

    After finding all the occurrences of the specific line, a last search operation is carried on, without success. So, the last #Line# line is replaced by two or more consecutive contents of the clipboard. Thus, a last task has to be done :

    Delete the few extra blocks of text that have been wrongly inserted, after the last match !

    As said above, this macro is not specific and can be used to insert any contents of the clipboard, in replacement of any specific text, even split on several lines, as long as the total amount of text is smaller than 2,048 characters ( Max size of the Find what: zone )

    So, now that the macro Replace Next Occurrence with Clipboard Contents has been created, the road map becomes :

    Create and select the text range which is to be replaced

    Open the Find dialog ( CTRL + F )

    Select, if necessary, the Normal search mode

    Leave all the other options unchecked

    Click on the Find Next button ( Whatever an occurrence of the range is found or not does not matter ! )

    Close the Find dialog ( Esc )

    Create and select the text range, in any file, even split on several lines, which will replace the initial range

    Copy this text range in the clipboard ( Ctrl + C )

    Now, open or select the specific file, where the replacements must occur

    If necessary, move to the very beginning of the file ( Ctrl + Home )

    Run the option Macro > Run a Macro Multiple Times...

    Select the Replace Next Occurrence with Clipboard Contents macro

    Tick the Run until the end of file option

    Click on the Run button

    Finally, delete the few extra range of text that have been wrongly inserted, after the last matched range !

    Best Regards

    guy038

  • How to insert text into the second line with RegEx in Notepad ++ ?

    21
    0 Votes
    21 Posts
    5k Views
    Thomas 2020T

    Schowek01.jpg

  • Add the Icon to the toolbar

    32
    0 Votes
    32 Posts
    10k Views
    Thomas 2020T

    Here some even write in Italian.

    The problem is to explain what problem I have with Notepad.
    Even the English don’t always understand each other.
    How I am trying to explain in short sentences
    some write that I am rude or arrogant.

    Today I figured out how to use
    Google translator.
    Dzisiaj wpadłem na pomysł jak używać Google translatora,
    aby tłumaczenie było jak najlepsze.

  • Problem with converting lowercase to uppercase

    12
    0 Votes
    12 Posts
    912 Views
    Thomas 2020T

    @mkupper said in Problem with converting lowercase to uppercase:

    as there are people who have Mc… style surnames where the third character is not upper-case

    e.g?

  • How do I sort words differently?

    7
    0 Votes
    7 Posts
    428 Views
    Thomas 2020T

    Briefly and succinctly.

    Schowek01.jpg
    there are over 1000 words

  • LaTeX delimiters

    2
    0 Votes
    2 Posts
    271 Views
    EkopalypseE

    If you are talking about the LaTeX lexer from Scintilla, it makes sense to make the request there,
    but if you are using a UDL, then we need more information about what exactly you do.

  • 7.8.8 problems with open files (on a network drive)

    3
    0 Votes
    3 Posts
    283 Views
    tseGITT

    just tested new 7.8.9 32bit --> same problem.
    But my special one can be solved. Instead of using .LOG als “SQL” i assigned “LOG” to VB / VB5 in stylers.xml. Now syntax highlighting is OK and the freeze is gone.

  • .bat file auto path updater

    4
    0 Votes
    4 Posts
    999 Views
    Michael VincentM

    @Alexander-Brkljac

    set file=%~dp0\OUTPUT.txt

    Cheers.

  • 0 Votes
    8 Posts
    452 Views
    astrosofistaA

    @Ekopalypse said in possibile creare una regola dal momento in cui si riceve file txt senza aprire il file?:

    wasn’t intended.

    OK, good to know that :)

    Just trying to be helpfull beyond service

    Which you do very well. Keep up the good work. :-)

    Sure, I always try to do my best, and as I understand, you do as well!

    Take care.

  • 0 Votes
    5 Posts
    341 Views
    PeterJonesP

    @guy038 said in Can we use "Copy Bookmarked Line" and "Paste in ReplaceWith" field in Macro:

    Hello, @b-sethi24, @alan-kilborn and All,

    Strange ! No answer regarding my assertion / question !

    Cheers,

    guy038

    I think you may have understood the original question differently than @Alan-Kilborn did. I made a similar interpretation at first, until I tried to figure out why Alan thought it wasn’t doable, when I original did. Re-reading the original post, I determined the key point was “Pasting in ReplaceWith field”.

    At first, like you, I thought @B-Sethi24 just wanted to paste the bookmarked lines in the document – in which case, the macro you showed would work.

    But if they really want to paste it into the REPLACE WITH field, with all the options available in the dialog box (including regex processing on the REPLACE WITH value), that cannot be done. (For example, if the line ${1} to ${10} were bookmarked, and they wanted to use that as the REPLACE WITH in a regex replacement.)

    Since @B-Sethi24 hasn’t come back since, I doubt we’ll get clarification anytime soon.

  • Refining smart highlighting to make current selection more obvious

    4
    1 Votes
    4 Posts
    382 Views
    EkopalypseE

    @James-Martin-0

    ahh I see, sorry I misunderstood.
    In that case it is the Selected text colour attribute.

  • same freeze but not on start up

    7
    0 Votes
    7 Posts
    2k Views
    tseGITT

    same problem. The problem is not the “line wrap” - option. Long lines are the problem.
    For better reading of my logfile i assigned extension LOG to type SQL in %appdata%\notepad++\stylers.xml.
    After Deassigning LOG works fine, so that will be my workaround until this problem is fixed by a future notepad version. No colored keywords but freezing the editor ist gone.

  • What command lets you copy cmd and save it in a new document?

    3
    0 Votes
    3 Posts
    332 Views
    Terry RT

    @Alexander-Brkljac said in What command lets you copy cmd and save it in a new document?:

    lets me copy the contents that is in cmd

    Try this link. It’s hardly NPP specific, but the paste portion should work in most apps, once the clipboard has received the marked area or piped output.

    https://www.labnol.org/software/copy-command-output-to-clipboard/2506/

    Terry

  • on clickable links - mouse cursor is flickering

    4
    0 Votes
    4 Posts
    357 Views
    mkupperM

    My cursor is not flickering when the mouse is over it but it flickers as I move the mouse left/right over a link. It’s possible your system is making npp think the mouse is moving.

    Try disabling and re-enabling clickable links to see if the flickering problem goes away until you exit/restart npp. The enable flag is in Settings / preferences / MISC. / Clickable Link Settings

  • Wildcard in replace field

    24
    1 Votes
    24 Posts
    10k Views
    Thomas 2020T
    (^| )(\d{1,2}:\d\d):(?=\d\d([ ,'!\.\?"”\)]|$))
  • How to remove all HTML tags except <p> or <h1> <h2> tags?

    4
    0 Votes
    4 Posts
    4k Views
    NZ SelectN

    I found this code will do the job
    </?(?!a)(?!p)(?!ul)(?!li)(?!h)\w*\b[^>]*>

  • Formula in Replace function

    3
    0 Votes
    3 Posts
    2k Views
    Terry RT

    @wielki-asasyn said in Formula in Replace function:

    I would like to replace the “D001” part of the name with D002, D003, D004 etc to have unique names.

    I thought I knew what you wanted, proceeded to produce a solution using regular expressions, then once I read your post again I’m not sure I have the correct interpretation. So I’ll ask some questions.

    The single line of example above, are there about 350+ similar lines of text needing replacing? Is the single line provided actually a portion of the 1 (and only) line in the file thus within that 1 line there will be approximately 350+ names?

    If the answer to #2 is yes, that’s the idea I followed. My solution involves a few steps. Firstly we’d need to cut this down into individual lines so each name was on a line by itself. Then we’d use the column editor to add an increasing number to the start of the line. Then we’d replace the existing “Dnnn” string with the number at the start of the line. Lastly we’d merge the records back into the original format.

    So my steps are.
    Using the Replace Function we have
    Find What:\|[^”]+”(?!})\K
    Replace With:\r\n

    Search mode MUST be regular expression. Click on the Replace All button.
    So now each name should be on a separate line. Note the regex uses a negative lookahead so that we don’t create a line with the } on it by itself.

    Now the cursor must be placed at the first line, first position, actually immediately before the first character. We use the Column Editor (under Edit main menu) and select “number to insert” and use initial number of 1, increase by 1 and leading zeros MUST be ticked, click OK. Provided you have correctly located the cursor you will now see every line is preceded by a 3 digit number, increasing by 1 each line. Since you say there were approximately 350+ names every number created should be 3 digits long as you requested.

    Now we use another regex to move this, replacing the existing number using Replace function.
    Find What:^(\d{3})(.+?)(“D)\d{3}
    Replace With:\2\3\1

    Again search mode MUST be regular expression and wrap around ticked. Click on the Replace All button

    Confirm the numbers have been correctly replaced. Last step is to join the separated lines back to the original format. So again using the Replace function.
    Find What:[^}]\K\R
    Replace With: nothing in this field, leave it empty.

    Click on the Replace All button and now you should have the format you wished with unique numbers for each name.

    Terry

  • 0 Votes
    6 Posts
    1k Views
    Alan KilbornA

    Additionally, here are some basic instructions for installing Pythonscript and getting a script to run:

    https://community.notepad-plus-plus.org/post/54655

    And here’s some stuff about binding the execution of a script to a keycombo:

    https://community.notepad-plus-plus.org/post/55131
  • Notepad++ 7.8.9 32bit freezes with dbf file

    11
    0 Votes
    11 Posts
    4k Views
    Jack SmitheJ

    @Ekopalypse
    I didn’t know about DBF Viewer Plus. I was given an assignment with a deadline and went to the tools I know how to use. I completed the assignment last night so this morning I was able to delve into the notepad++ issue and discovered the source of the problem. Thank you for telling me about DBF Viewer. Once I figure out how to use it it will be a big help. If all I have is a hammer everything looks like a nail. Now I have a crowbar so now I can do more with less effort.

    @Alan-Kilborn
    The dbf is 6 lines long according to Notepad++. Line 6 is the one I am interested in which takes up 98% of the file. Now that I have DBF Viewer that should make things easier in the future. I will definitely keep this in mind for if I can’t use DBF Viewer.

  • Change Indent Keyboard Shortcut?

    27
    0 Votes
    27 Posts
    12k Views
    Alan KilbornA

    Here’s a weird condition…maybe:

    Select one or more empty lines.
    Press Tab.
    Exactly nothing happens.

    My goal was to have leading whitespace inserted on all lines at once, for each press of the tab key.