How to move the cursor(s) to the next occurence of a character in Sublime Text

sublime-textsublime-text-2sublime-text-3

Let's say we have a file containing this:

name, job, age
Mark, Specialist, 24
Bob Guy, Manager, 43
Susan Third, Data Generation, 30

What I want to do is navigate around the fields. Move to the next field, select a field, etc. This is easily done in VIM by looking for commas (and assuming there are no escaped commas); is it also possible in Sublime Text? And in a way that works with multiple cursors, say one at the beginning of each line?

Bonus points if you can extend it to moving to the next substring or regex match.

Best Answer

In your particular use case, a good search to perform to isolate each value would be \w[^,\n]+ - make sure to click the regex button or hit Alt+R (Windows) / Cmd+Option+R (Mac) in the search field.

To navigate to the next match, use F3 (Windows) / Cmd+G (Mac). Shift+F3 / Cmd+Shift+G will navigate to the previous match. You can continue doing this after hitting Esc to dismiss the search field, and this will allow you to immediately edit the selected match.

Unfortunately, it doesn't appear that find-next can coexist with multiple selections - it ends up highlighting the first match in the last selection. You could highlight multiple lines, then split the selection into lines, then use Ctrl (Windows) / Cmd (Mac) + or arrows to some degree, but that will obviously fall apart when some values have spaces.

Related Question