Live data from Hacker News

Some things beginners might not know about Sublime Text

blog.alainmeier.com

41–50 of 116 posts

Re: Some things beginners might not know about Sublime Text

#41
post #36
post #31

Earlier quoted context omitted.

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 [1] http://ajaxorg.github.com/ace/build/kitchen-sink.ht…

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.

Re: Some things beginners might not know about Sublime Text

#44
post #34

Cmd-P is useful for opening existing files, but what's the preferred way for creating them? I eventually had to get an extension and modify it to replicate emacs' c-x c-f to create files.

I normally do Cmd+N (Create an empty file) Cmd+S (save it). Isn't this sort of the same?

Re: Some things beginners might not know about Sublime Text

#45
post #25
post #15

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.

Re: Some things beginners might not know about Sublime Text

#46
post #44
post #34

Cmd-P is useful for opening existing files, but what's the preferred way for creating them? I eventually had to get an extension and modify it to replicate emacs' c-x c-f to create files.

I normally do Cmd+N (Create an empty file) Cmd+S (save it). Isn't this sort of the same?

That uses the OS file dialog, which is far too slow for my taste, although I've never actually checked to see what kind've shortcuts there are for it.

Re: Some things beginners might not know about Sublime Text

#47
post #34

Cmd-P is useful for opening existing files, but what's the preferred way for creating them? I eventually had to get an extension and modify it to replicate emacs' c-x c-f to create files.

Sqoot Co-Founder Back to Blatant Sexism:

https://twitter.com/avand/status/224401243961954304

Re: Some things beginners might not know about Sublime Text

#48

You can also move the curent line up and down the page using Ctrl + Cmd + Up/Down

Or on Windows, it’s Ctrl+Shift+up/down.

Also:

Ctrl+Shift+D duplicates the current line by default (or the current selection, if any). Ctrl+Shift+K deletes the whole line. Ctrl+K twice deletes to end-of-line. Ctrl+K Ctrl+backspace deletes to beginning-of-line.

Combine duplicate, move up/down, and the Ctrl+D multi-cursor stuff, and you have a copy-and-paste coder’s dream editor. ;-)

Re: Some things beginners might not know about Sublime Text

#49
post #15

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.

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
Post reply on HN