Notepad++ snippets

How to insert a code for each X lines in Notepad++

Let say you have the following list of temporary tables in SQL:

Notepad++ replace 1

INSERT INTO company_details VALUES('E40001','AE1071',36);
INSERT INTO company_details VALUES('E40002','AE1041',21);
INSERT INTO company_details VALUES('E40003','AE1051',38);
INSERT INTO company_details VALUES('E40004','AE1021',34);
INSERT INTO company_details VALUES('E40005','AE1021',28);
INSERT INTO company_details VALUES('E40006','AE1061',23);
INSERT INTO company_details VALUES('E40007','AE1061',36);
INSERT INTO company_details VALUES('E40008','AE1071',88);
INSERT INTO company_details VALUES('E40009','AE1071',97);
INSERT INTO company_details VALUES('E40010','AE1071',38);
INSERT INTO company_details VALUES('E40011','AE1091',88);
INSERT INTO company_details VALUES('E40012','AE1041',26);
INSERT INTO company_details VALUES('E40013','AE1011',31);
INSERT INTO company_details VALUES('E40014','AE1021',20);
INSERT INTO company_details VALUES('E40015','AE1031',20);
INSERT INTO company_details VALUES('E40016','AE1011',31);
INSERT INTO company_details VALUES('E40017','AE1021',27);
INSERT INTO company_details VALUES('E40018','AE1031',88);

and you want transform them into the following:

Notepad++ replace 3

INSERT INTO company_details VALUES('E40001','AE1071',36);
INSERT INTO company_details VALUES('E40002','AE1041',21);
INSERT INTO company_details VALUES('E40003','AE1051',38);
COMMIT;
INSERT INTO company_details VALUES('E40004','AE1021',34);
INSERT INTO company_details VALUES('E40005','AE1021',28);
INSERT INTO company_details VALUES('E40006','AE1061',23);
COMMIT;
INSERT INTO company_details VALUES('E40007','AE1061',36);
INSERT INTO company_details VALUES('E40008','AE1071',88);
INSERT INTO company_details VALUES('E40009','AE1071',97);
COMMIT;
INSERT INTO company_details VALUES('E40010','AE1071',38);
INSERT INTO company_details VALUES('E40011','AE1091',88);
INSERT INTO company_details VALUES('E40012','AE1041',26);
COMMIT;
INSERT INTO company_details VALUES('E40013','AE1011',31);
INSERT INTO company_details VALUES('E40014','AE1021',20);
INSERT INTO company_details VALUES('E40015','AE1031',20);
COMMIT;
INSERT INTO company_details VALUES('E40016','AE1011',31);
INSERT INTO company_details VALUES('E40017','AE1021',27);
INSERT INTO company_details VALUES('E40018','AE1031',88);
COMMIT;

To do this in Notepad++, you can just hit CTRL + H for Replace window and the select the following:

Notepad++ replace 2

  • Find what: (.*\r?\n){3}\K
  • Replace with: COMMIT;\n
  • Flag Regular expression
  • Do not flag . matches new lines

Back to Notepad++ cookbook page