How to add something every x line

How do I add

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

to every X line in a text document?


Solution 1:

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.

Solution 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