Sublime text 3, multiline select, how to go to a specified characted (on all lines)?

2

1

I have a CSV like this

id,name,city
1,John,New York
10,Peter,Los Angeles
223,Joseph,London

I'm in multiline select mode. I obtained the multiline cursor by selecting all the rows I needed and pressed ctrl+shift+L. I then pressed the home key, to go to the beginning of the line.

How would I select only the ids in this CSV (which of course is a lot larger than 3 lines)

I can for instance select a section like this, by holding the shift key and then the right arrow 3 times

1,J
10,
223

...but this is not what I want, rather I'd need this

1
10
223

Any way I can do this? I don't want to have to open vim unless it's absolutely necessary.

vlad-ardelean

Posted 2016-11-17T16:09:02.080

Reputation: 167

Answers

1

Here's what I would do:

CMD + A (select all)
CMD + SHIFT + L (multi line select mode)
CMD + LEFT ARROW (go to left of selection)
SHIFT + ALT + RIGHT ARROW (select first column)

With this input:

1,John,New York
10,Peter,Los Angeles
223,Joseph,London

It selects:

1
10
223

Note that I'm on Mac so I guess you have to use 'CTRL' instead of 'CMD'.

ayaio

Posted 2016-11-17T16:09:02.080

Reputation: 290

That does work, but has some limitations. For instance, if one of the IDs contains a dash while the others don't, then this doesn't work. – vlad-ardelean – 2016-11-28T13:19:16.723

0

I would suggest using the Find functionality instead of multiple cursors / multiline edit mode, although the following would also work with multiple cursors as long as the selection still covers the ids (i.e. so don't press Home).

  • Select the lines you are interested in, then open the Find panel (Find menu -> Find...).
  • Tick "In selection"
  • Ensure "Regular expression" mode is enabled
  • Enter ^[^,]* as the search string
  • Click the "Find All" button

This regular expression basically says: begin searching at the start of every line (in the selection) for any number of characters (including 0, in case some ids are missing, for example) that are not a comma.

Keith Hall

Posted 2016-11-17T16:09:02.080

Reputation: 331