Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multiple selection every N lines Sublime Text

I have a very large file (~100k lines) and I want to insert a comment every 100 lines, I can write a script to do it, but I wonder if something like this is possible in Sublime (In emacs is pretty straightforward).

like image 305
Mateo Torres Avatar asked Sep 01 '14 15:09

Mateo Torres


People also ask

How do you type in multiple lines at once in Sublime Text?

To select multiple regions using the keyboard, select a block of text, then press Ctrl+Shift+L to split it into one selection per line. When you're done with using multiple selections, just press Ctrl+K to trim all but the first.

How do you edit multiple lines in Sublime Text 3?

Alternatively you can select lines and go to SELECTION MENU >> SPLIT INTO LINES. Now you can edit multiple lines, move cursors etc. for all selected lines.


1 Answers

How about this regex to find 100 lines at a time

((.*\n){1,100})

and then replace with

\1
// this is a comment

Is that close enough for whatever it is you are trying to achieve?

Edit: This version of the replacement text suggested as better by @Maluchi

\1\n
// this is a comment\n
like image 52
jwpfox Avatar answered Sep 20 '22 02:09

jwpfox