Hacker News new | comments | show | ask | jobs | submit login

Cmd + d selects the current word.

Subsequent Cmd + d presses will select the following instance of the word for editing. Makes it easy to do things such as renaming a local variable or changing both the opening and closing element of a HTML tag.

What's really wild is if you do CMD+d several times and then move around with the arrow keys. Multiple cursors follow you around. I'm not sure if this is useful, but it's certainly cool.

To me, supporting multiple cursors is one of ST2’s killer features.

For one thing, it goes a surprisingly long way to making up for not having language-sensitive refactoring tools if you’re renaming things, changing parameter lists, etc.

Also, you can make a selection in advance rather than relying on the default of selecting the current word. That selection can even span line breaks and/or include indentation. If you then select some/all instances of the same text as starting points using Ctrl+D, you can change not only the copies of the text but also (for example) extend the selections to include whatever is immediately before or afterwards (even if that is different in each case) or move to the start or end of each line. It’s a quick way to do a lot of common search-and-replace type operations without getting bogged down in regexes or macros.

A related useful technique is using (on Windows) Ctrl+Alt+up/down, which moves up/down a line creating multiple cursors as you go. If you then do Shift+left/right, you can get a “column selection” effect, for example. (You can also drag with the middle mouse button to select a column.)

I hope ST2 will build on these basic features as time goes on. It could allow incremental forward/backward search without cancelling the multiple cursors, let you cycle around which cursor is shown or will be left when you hit escape to cancel multiple mode, maybe even temporarily split the display to show multiple cursors at once if they are far apart. There’s a huge amount of potential here.

Way useful. You can, for example, select all instances of a variable name, then rename it selectively from the middle of the selection if you want.

Also good to note: Command-F find also has a "Find All" option which can be faster than pressing Command-D multiple times, and also allows more complex non-word and regexp searches. From there you can use multiple cursors or replace the whole selection just by typing.

Brilliant editor, this one.


One minor complaint: I wish cmd+D had a "whole words only" setting. Its confusing when using with the "highlight all matches" feature, which is "whole words only" IIRC.

Also notable is that you can skip the currently selected element (i.e. unselect it) if you press ctrl+k+d. Sublime will then continue to select the next word, but leaves the one you just selected unselected.

ctrl+k+d was added recently and was quite a big improvement but it's still hard to use because if you do one wrong cmd+d you'll have to either start again or use the mouse. the way cloud9 ace[1] handles this is better, since it keeps last added selection as active one and from there you can add selections with ctrl+alt arrows or remove with ctrl+alt+shift arrows


If you press ctrl+d one time too many, you can use Soft Undo (ctrl+u / command+u) to step backwards. Soft Undo undoes selection commands as well as modifying commands, as opposed to regular undo, which undoes modifying commands only.

another fast way to select all instances of a word/phrase for editing is to find in file (cmd+f) type out your variable/whatever and then option+enter will find all instances of your search text and highlight each for editing via their own cursor

This doesn't seem to do anything for me, (on mountain lion)

Applications are open for YC Summer 2018

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact