How do I add

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

to every X line in a text document?

  • 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

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

  1. Find what:

  2. Replace:

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

  4. Then press Replace All

You can test it at regex101.

| improve this answer | |
  • 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

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


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

| improve this answer | |
  • 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

I'm note sure if it works in Notepad++, but this is how I solved it with PSPads phReplace:




$1New Line[Enter]

[Enter] stands for pressing the Enter-Button as phReplace does not allow \r\n in replace field.

| improve this answer | |
  • How is this better than @psxls answer? – Toto Aug 11 '19 at 16:35
  • @Toto His answer did not work for me. – mgutt Aug 11 '19 at 20:27
  • It is strictly the same but condensed – Toto Aug 11 '19 at 20:53

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