14

How do i add

Keyboard : E : KeyDown DELAY : 1300 Keyboard : E : KeyUp DELAY : 200

TO Every X Line in a text document?? anyone? =)

Like every 9 line i want ==

Keyboard : E : KeyDown DELAY : 1300 Keyboard : E : KeyUp DELAY : 200

to be

  • 1
    You can simply do it with a programming language like C or Java. – Ali Hashemi Nov 25 '13 at 16:01
  • Can you be a little more specific about what your file already contains and what you'd like it to be replaced with? This can probably be done using the find/replace regular expressions feature of Notepad++, but I'd have to get a clearer example (similar to the example here) to provide a solution. – allquixotic Nov 25 '13 at 16:25
  • FYI you can do it online as well textmechanic.com/text-tools/basic-text-tools/… – Franck Dernoncourt Mar 14 '16 at 19:57
21

To insert a new line after every 9 rows, go to Search > Replace menu (shortcut CTRL+H) and do the following:

  1. Find what:

    (.*\r?\n){9}\K
    
  2. Replace:

    Your new line\n
    
  3. Select radio button "Regular Expression"

  4. Then press Replace All

You can test it at regex101.

  • 1
    This worked for me. But don't forget to uncheck the [x] ". as linebreaks" checkbox for regular search. – patrics Jan 7 '16 at 20:21
  • Worked great, thanks! Note, if your new line has any special regex characters like \ or *, you'll need to escape them with a backslash. \\ or \*. – twasbrillig Jan 9 '17 at 21:37
  • Apperently \K is a little bug for replacing. In my case I needed to use capture groups similar to the other answer instead of using \K. – AaronLS Feb 1 '18 at 21:40
2

Still using search/replace, this worked better in my case: selects [your example 9 lines] in one group (the inner '()' pair for each line followed by 'newline'), then the '{}' pair for the look-ahead line count to grab, and the outer '()' pair for the 9 lines retained as a group

((.*\n){9})

Use the \1 variable to restore the same [9] line group, followed by [your sample line insert] and a newline

\1\nKeyboard : E : KeyDown DELAY : 1300 Keyboard : E : KeyUp DELAY : 200\n

  • Please read the question again carefully. Your answer does not answer the original question. – DavidPostill Aug 31 '16 at 7:20
  • Tweaked to match OP syntax – netify Oct 19 '16 at 18:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.