Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put cursor on every other line (on alternate lines)

How can I put cursor on every other line (on alternate lines).

For example, I want to put cursor on line 1,3,5,7....

How can I do that?

I know I can do that by AltClick. But there are too many lines and an easier way will be very helpful.

like image 321
blueray Avatar asked Oct 26 '25 03:10

blueray


1 Answers

You can do this with a regex:

  1. Find: ^(.*\n){1}.*$

  2. With focus on the find input, hit Alt+Enter. It will select all those matches - every two lines. Or if focus is in the editor, hit Ctrl+Shift+L - it'll do the same thing.

  3. Home to put cursor at beginning of those selections. (If you have spaces or tabs at the beginning of a line, just hit Home until you are at the beginning.)

  4. UpArrow or DownArrow to move those cursors where you want.

put a cursor on every other line demo


Obviously this scales pretty easily:

Find: ^(.*\n){2}.*$ for every third line, ^(.*\n){3}.*$ for every fourth line, etc.

like image 144
Mark Avatar answered Oct 28 '25 20:10

Mark



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!