Sublime Forum

How to select a ligne every X lignes

#1

Hi !

First of all, thanks a lot for Sublime Text, it’s awesome :smile:

I need to select a ligne every three line (select line 1, line 4, line 7, etc…). How can I do that ?

Ythio.

0 Likes

#2

There are a variety of ways. One way is to use Find with a regular expression like “.\n.\n.*\n”, use Find All, then press left arrow to convert to single selection cursors.

Alternatively you can record a macro.

0 Likes

#3

Open the console and type:

view.sel().add_all([sublime.Region(view.text_point(x, 0)) for x in range(0, view.rowcol(view.size())[0]+1, 3)])

If you need this feature regularly, create a plugin.

sapphirehamster solution is smarter and good enough for sporadic use (you can simplify the RE a little “(.*\n){3}”).

0 Likes