I have a CSV like this
id,name,city
1,John,New York
10,Peter,Los Angeles
223,Joseph,LondonI'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
223Any way I can do this? I don't want to have to open vim unless it's absolutely necessary.
2 Answers
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'.
1I 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.