Installation is through the Sublime Text 2 console. This is
accessed via the ctrl+` shortcut. Once open, paste the following command
into the console:
import urllib2,os; pf='Package
Control.sublime-package'; ipp=sublime.installed_packages_path();
os.makedirs(ipp) if not os.path.exists(ipp) else None;
urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler()));
open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbon
d.net/'+pf.replace(' ','%20')).read()); print 'Please restart Sublime
Text to finish installation'
Are you kidding me? The product or package maintainer should handle this better.
You guys know that you can go to the Default Keymaps file and get all of these tips in one list right? You can even change them...
EDIT: Just for fun, here is that file on OS X: https://gist.github.com/3117613 Notice the "context" definitions. Also check out how the auto-pairing functionality is defined in terms of the key binding DSL. And how you can define nonstandard layouts for the panes. And so on.
Sublime is great. It reminds me of a less insane version of Foobar2000.
I actually really like getting other people's lists of their favorite ST2 features. It's more digestible than getting the entire list in one go. I find I tend to get one or two features that I put into "rotation" in reading these, while looking at all the keybindings just overwhelms me and leaves me using the features I already know.
Ctrl+Alt+P to get a dialog for opening all your Sublime projects.
Ctrl+R for navigating to functions or classes within the current file.
SublimeClang gives you Visual Studio-style Intellisense, static analysis, and jump to definition/implementation.
When setting up Vim emulation, you'll need to install VintageEx and change some of the default bindings (Ctrl+Shift+P+"key" to see the binding files). You'll also want SublimeBlockCursor.
For example, put the following in the user defined keymap to override the defaults:
[
{ "keys": ["ctrl+f"], "command": "move", "args": {"by": "pages", "forward": true} },
{ "keys": ["ctrl+b"], "command": "move", "args": {"by": "pages", "forward": false} },
{ "keys": ["ctrl+shift+f"], "command": "move", "args": {"by": "pages", "forward": true, "extend": true} },
{ "keys": ["ctrl+shift+b"], "command": "move", "args": {"by": "pages", "forward": false, "extend": true} }
]
Further to point F: if you hold down control, you move by word segment - this is camel-case (and underscore) aware. So, if I am at the front of the word "cakeParty", I can move to between 'e' and 'P' by holding control and pressing the right arrow key.
(This is in ST2 for Mac OS X - I'm sure there's an equivalent feature in ST2 for other systems.)
The command and alt modifiers work when I use the arrow key but this ctrl doesn't seem to do anything... OS X lion. For example, I put the caret in front of a camelCased variable and press ctrl+right arrow, nothing happens. Am I doing it wrong?
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.
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.
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
Something else you might not know -- multiple selection via command clicking (also implemented in Excel, for example) was in the original (1985ish) Apple Humn Interface Guidelines.
Now that I think about it, it's such a common feature everywhere except text editing (I'm mainly thinking of selecting/highlighting things like icons and menu items) it's interesting that it has taken so long to be an editor's big selling point.
Another one i've found useful is CMD+D / CMD+K+D. CMD+D finds the next instance of the current selection and creates another cursor there (and selects it as well). CMD+K+D skips the current selection and finds the next one.
I curse myself whenever I think about it. For the longest time, I didn't know about this shortcut. I missed it terribly, but I was too thick to understand that I can search through the manuals or internet to find if such a shortcut exists... I used it a hundred times daily (Java, Eclipse), but the need for it is much greater in CoffeeScript+Node.js
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. ;-)
I've been using {g}vi{m} for 20 years now, but just bought ST2. I like how this whole discussion revolves around finding keystrokes in ST2 that yield the convenience of doing things I took for granted in vim. Maybe I should just yield to the wisdom of the crowd, go back to VIM, forget about having a file explorer on the left side (NERDtree's wonkiness drove me to ST2), and learn to use Ctrl-P. It's what people keep suggesting to use in ST2.
I tried out Sublime for a day or two, and think it does a lot of things right. However a few small things also bugged me right off the bat, may be someone can help.
- Code folding:
No fold level 1 option, would like a hotkey.
No line at the fold, just an icon at end of line.
- No GUI for options or syntax/theme editing. I give geany a pass on this (has options but not theme
editing) because it is free. Many other free choices have
this (N++, Programer's Ed.) but not Sublime. I don't wanna
dig through docs for hours (again) to get another editor set
up. It's a shame this stuff isn't standardized by now.
This might be because they made their own widget set and
haven't finished yet. If so, it was a mistake. QT, wx, or
native would have been fine. No need to reinvent the wheel.
Configuration: The mess of weird filenames and extensions in the config folder was a turnoff also. Json is nicer in many respects than xml, but I can't say it's optimal for config files.
> This might be because they made their own widget set and haven't finished yet. If so, it was a mistake.
I don't understand how anyone who has actually used Sublime can say this. It's smooth, clean, cross-platform identical, and beautiful, and most importantly, insanely fast. I believe the widget set is their biggest strength.
Then again, I also believe the text configuration is another strength. It's a programmer's editor; it wasn't designed this way out of laziness or poor aesthetic or UI concepts, it was designed this way because it's exactly how most of the target users want to configure it. It also saves a lot of dev time that would be spent maintaining myriad settings UI's and determining which belong and which don't and how to lay them out and how to document them, etc. etc. etc. Instead, settings are keys and the way you manage them is through simple, readable JSON files. No problem.
It also has many other advantages, such as being able to have a settings file per project and override any settings as you like, rather than being limited by a pesky UI.
In fact, it would probably be a fairly easy thing to set up a Sublime plugin that provides a UI for the various settings as you desire. The fact that no one has bothered to do this yet is very telling.
You can also get multiple cursors from the keyboard with ctrl+alt+(uparrow or downarrow) not the most convenient of keybindings but can be rebound if you look for "select_line" in the default keybindings. (Linux and Windows)
You can also search and do multiple selection with a regular expression, which is awesome. I've used this heavily in the past few weeks. The only problem I've had is that all searches appear to run on the main thread, so when working on a sufficiently large file, the whole application blocks like hell. And to make it even worse, they update search results on the fly, meaning that for every new character you enter it blocks. I've taken to writing my expressions fully in a random textfield elsewhere, and pasting them in all at once.
Things sublime text lacks that bug me: drag and drop of selections. It would be even better if it could do what nedit can do with drag and drop, or drag and clone of both normal and block selections.
You can also use your middle mouse button to make block selections, or doing things like making a long vertical line of multiple cursors (handy if you have an HTML list of varying line lengths, you can draw a long vertical line of multiple cursors, then use the left and right arrow keys and home and end keys to make changes to all of the lines quickly).
[+] [-] po|13 years ago|reply
http://wbond.net/sublime_packages/package_control
Useful for installing things like themes, syntax awareness, code linters, etc...
[+] [-] mixmastamyk|13 years ago|reply
[+] [-] JonnieCache|13 years ago|reply
EDIT: Just for fun, here is that file on OS X: https://gist.github.com/3117613 Notice the "context" definitions. Also check out how the auto-pairing functionality is defined in terms of the key binding DSL. And how you can define nonstandard layouts for the panes. And so on.
Sublime is great. It reminds me of a less insane version of Foobar2000.
[+] [-] MaxGabriel|13 years ago|reply
[+] [-] salsakran|13 years ago|reply
[+] [-] sev|13 years ago|reply
[+] [-] siodine|13 years ago|reply
Ctrl+R for navigating to functions or classes within the current file.
SublimeClang gives you Visual Studio-style Intellisense, static analysis, and jump to definition/implementation.
When setting up Vim emulation, you'll need to install VintageEx and change some of the default bindings (Ctrl+Shift+P+"key" to see the binding files). You'll also want SublimeBlockCursor.
For example, put the following in the user defined keymap to override the defaults: [ { "keys": ["ctrl+f"], "command": "move", "args": {"by": "pages", "forward": true} }, { "keys": ["ctrl+b"], "command": "move", "args": {"by": "pages", "forward": false} }, { "keys": ["ctrl+shift+f"], "command": "move", "args": {"by": "pages", "forward": true, "extend": true} }, { "keys": ["ctrl+shift+b"], "command": "move", "args": {"by": "pages", "forward": false, "extend": true} } ]
[+] [-] redfloatplane|13 years ago|reply
(This is in ST2 for Mac OS X - I'm sure there's an equivalent feature in ST2 for other systems.)
[+] [-] ashamedlion|13 years ago|reply
[+] [-] mattacular|13 years ago|reply
[+] [-] haasted|13 years ago|reply
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.
[+] [-] foz|13 years ago|reply
[+] [-] Xymak1y|13 years ago|reply
[+] [-] Xoriff|13 years ago|reply
[+] [-] jameswyse|13 years ago|reply
[+] [-] Osmose|13 years ago|reply
I eventually had to get an extension and modify it to replicate emacs' c-x c-f to create files.
[+] [-] fserb|13 years ago|reply
[+] [-] 500mistakes|13 years ago|reply
[deleted]
[+] [-] mef|13 years ago|reply
- Goto file: "con pos" -> app/controllers/posts_controller.rb
- Goto line in file: "con pos:100" -> app/controllers/posts_controller.rb line 100
- Goto function in file: "con pos@foo" function foo in app/controllers/posts_controller.rb
Also one that came up recently is CMD+ALT+Q to auto-wrap long comments to your ruler (e.g. 80 columns).
[+] [-] JonnieCache|13 years ago|reply
[+] [-] Tloewald|13 years ago|reply
[+] [-] dt7|13 years ago|reply
[+] [-] toran1302|13 years ago|reply
A fine grained find+replace/modify :)
[+] [-] draftable|13 years ago|reply
[+] [-] pooriaazimi|13 years ago|reply
[+] [-] Chris_Newton|13 years ago|reply
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. ;-)
[+] [-] LocalPCGuy|13 years ago|reply
[+] [-] Dunkirk|13 years ago|reply
[+] [-] kamechan|13 years ago|reply
edit: back at my computer now. to put st2 into vim mode, just comment this line out in the default preferences:
[+] [-] Lost_BiomedE|13 years ago|reply
[+] [-] tyrmored|13 years ago|reply
[+] [-] mixmastamyk|13 years ago|reply
- Code folding: No fold level 1 option, would like a hotkey. No line at the fold, just an icon at end of line.
- No GUI for options or syntax/theme editing. I give geany a pass on this (has options but not theme editing) because it is free. Many other free choices have this (N++, Programer's Ed.) but not Sublime. I don't wanna dig through docs for hours (again) to get another editor set up. It's a shame this stuff isn't standardized by now.
This might be because they made their own widget set and haven't finished yet. If so, it was a mistake. QT, wx, or native would have been fine. No need to reinvent the wheel.
Configuration: The mess of weird filenames and extensions in the config folder was a turnoff also. Json is nicer in many respects than xml, but I can't say it's optimal for config files.
[+] [-] calinet6|13 years ago|reply
I don't understand how anyone who has actually used Sublime can say this. It's smooth, clean, cross-platform identical, and beautiful, and most importantly, insanely fast. I believe the widget set is their biggest strength.
Then again, I also believe the text configuration is another strength. It's a programmer's editor; it wasn't designed this way out of laziness or poor aesthetic or UI concepts, it was designed this way because it's exactly how most of the target users want to configure it. It also saves a lot of dev time that would be spent maintaining myriad settings UI's and determining which belong and which don't and how to lay them out and how to document them, etc. etc. etc. Instead, settings are keys and the way you manage them is through simple, readable JSON files. No problem.
It also has many other advantages, such as being able to have a settings file per project and override any settings as you like, rather than being limited by a pesky UI.
In fact, it would probably be a fairly easy thing to set up a Sublime plugin that provides a UI for the various settings as you desire. The fact that no one has bothered to do this yet is very telling.
[+] [-] ohgodthecat3|13 years ago|reply
[+] [-] unknown|13 years ago|reply
[deleted]
[+] [-] nottombrown|13 years ago|reply
Want to Save-all? Cmd-Shift-P, type 'save' and hit enter. Plus it takes into account any customizations or add-ons you might have put together.
[+] [-] eogas|13 years ago|reply
[+] [-] JulianMorrison|13 years ago|reply
[+] [-] unknown|13 years ago|reply
[deleted]
[+] [-] president|13 years ago|reply
[+] [-] dt7|13 years ago|reply