Hacker News new | ask | show | jobs
by foz 5080 days ago
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.
2 comments

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.

+1.

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.