
Some things beginners might not know about Sublime Text - ashamedlion
http://blog.alainmeier.com/post/27255145114/some-things-beginners-might-not-know-about-sublime-text
======
po
Also a must-have: Sublime Package Control

<http://wbond.net/sublime_packages/package_control>

Useful for installing things like themes, syntax awareness, code linters,
etc...

~~~
mixmastamyk

        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.

~~~
modarts
Um, this is product for developers. I think that they should be able to handle
a pretty simple copy/paste. Not sure the reason behind the drama queenery.

~~~
mixmastamyk
If it's worth doing, it's worth doing right. Respect others and they will
respect your work.

~~~
natrius
This is a worthless, false platitude.

~~~
mixmastamyk
So we know your stance on courtesy and respect to others.

~~~
natrius
It needed to be said, and the style was intentional. Statements like the one
you made sound right and are easy for readers to accept as fact. My comment
was intended to make people go back and reevaluate yours. I think it was
accurate, effective rhetoric. It wasn't intended as a judgment of your worth;
just as a judgment of that particular comment's worth.

~~~
mixmastamyk
It reads as if you're more interested in stamping out cliches rather than if
the cliche is true or not in this instance.

------
JonnieCache
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.

~~~
sev
Thanks for that. Off topic: Safari on iPhone cuts off every line short at your
link...I'm surprised by github!

~~~
lparry
They're not actually cut off, they're in a scrollable text area (use two
fingers to scroll within that text area) same as on the desktop. Not very easy
to use, but then the device does have a very low (virtual/apparent) resolution
of 320x480.

------
siodine
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} } ]

------
hebejebelus
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.)

~~~
ashamedlion
I added your tip to the list, thanks!

~~~
Calvein
On Linux (and WIndows I presume) it's with the alt key.

------
haasted
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.

~~~
foz
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.

~~~
calinet6
_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.

~~~
swah
+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.

------
Osmose
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.

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

~~~
h0munculus
But then syntax highlighting is off until you close and reload it, which is
annoying. I usually have a terminal open to the project anyway so I just use
'touch' to create the file I want.

~~~
jskinner
By default, the appropriate syntax highlighting will be set on the file the
first time it gets saved.

------
mef
One of my favorite features is the flexibility of the Goto Anything dialog
(CMD+T or CMD+P) e.g.:

\- 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
You dont even need the spaces.

    
    
        "conpos:100"
    

works fine.

------
Tloewald
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.

~~~
dt7
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.

------
toran1302
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.

A fine grained find+replace/modify :)

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

~~~
pooriaazimi
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

------
LocalPCGuy
For those that like/need to print their code, there is a plugin that does
that: <https://github.com/joelpt/sublimetext-print-to-html>

------
Dunkirk
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.

~~~
kamechan
There's a vim mode in st2. I'm not near my computer at the moment but IIRC
it's in the preferences (classic mode I think it's called?).

edit: back at my computer now. to put st2 into vim mode, just comment this
line out in the default preferences:

    
    
       "ignored_packages": ["Vintage"]

------
mixmastamyk
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.

~~~
calinet6
> 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.

~~~
mixmastamyk
I didn't say it shouldn't be saved to disk as text. I gave three editors which
have gui configs as well and are free. The gui can be built automatically if
done right.

Also, I have no performance issues with any of my editors. The widget comment
was based on the fact they use no other widgets, they must not have written
them yet.

------
ohgodthecat3
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)

------
nottombrown
Cmd-Shift-P is incredibly useful. It lets you intelligently search all the
commands.

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
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.

------
JulianMorrison
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.

------
dt7
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).

------
aviraldg
I hadn't noticed this before, but you can create a new file by (double?)
clicking anywhere in the empty area in the tab bar.

~~~
taitems
Really? This is the one thing I've been missing from Notepad++ that I could
never get working in either the Windows or Mac versions of ST2. Maybe it
landed in that update last night or the night before.

------
pastr
For more ST keyboard shortcuts: <https://gist.github.com/1736542>

------
noiv
Despite ST2 is great and everyday there is a new surprising feature to detect
- what is the shortcut for 'save all'?

~~~
siodine
First, search google for "sublimetext save all." You should then get this
website <http://www.sublimetext.com/docs/commands>.

Now, create a new user defined bind for that command (you can google how to do
this). Or you could use Ctrl+Shift+P+"save".

------
rockzapper
The shortcut to quickly open Files is Ctrl + P (or Cmd + P on Mac) as opposed
to Ctrl + T mentioned in the article.

------
draftable
To quickly get multiple cursors on many lines at once, you can also select
what you need and hit Cmd + Shift + L

------
tixzdk
I've kept my favorite shortcuts open in a panel for about a week, so I could
learn them by heart: <http://pastebin.com/hQtYKzhN> Favorites include: Expand
selection (to various levels), close tag, block commenting and splitting
lines!

------
madprops
ctrl + t swaps text, for example foo(bar) if you place the cursor before the
parenthesis and press ctrl + t it will become bar(foo).

ctrl + m when in a bracket sets the cursor to it's matching bracket.

ctrl + up or ctrl + down scrolls the document up or down.

ctrl + g goes to a line.

------
taylorbuley
Is it possible to do multi-line editing like Sublime Text but in Vim? I use
both, and this was the feature that got me out of Terminal, but besides this I
can't think of anything else offhand for what ST2 can do that Vim can't do.

~~~
madelfio
Yes, Ctrl-v to enter visual-block mode, then move up or down to cover all
lines where you want to make changes, then I{string}Esc to append a string at
the cursor location on all lines.

See:
[http://vimdoc.sourceforge.net/htmldoc/visual.html#blockwise-...](http://vimdoc.sourceforge.net/htmldoc/visual.html#blockwise-
operators)

~~~
mvgoogler
Doesn't block mode only work for blocks within contiguous lines of code?
(basically it will let you select a rectangular section of code)

ST2 allows multiple cursors in arbitrary locations - I'm not aware of another
editor that supports that.

~~~
jagira
There is a vim plugin that provides arbitrary multiple line edit.

<https://github.com/alfredodeza/plexer.vim>

------
B-Scan
Ctrl+Shift+D duplicates line

------
mise
Here's a (PC-oriented) cheat sheet of some keyboard shortcuts:

<https://gist.github.com/1958143>

------
trebor
CMD/CTRL + R will take you immediately to the find by symbol/definition. This
is the same as CMD/CTRL + P and then typing @.

------
deviarte
I am pretty sure that "Quick file opening" is CTRL+P on Windows. Since CTRL+T
opens a new tab for me..

~~~
mathieuh
Yep. Basically, Textmate's Goto Anything feature is activated by cmd+t, so
ST's author mapped both cmd+t and cmd+p to Goto Anything on OS X to
accommodate people switching over. On OS X, Goto Symbol is actually cmd+r.

~~~
steverandy
I set cmd+t for goto anything and cmd+p for command palette.

------
prisonguard
switched to sublime from np++ 3 months's ago, happy bunny! but i miss the np++
file explorer that allowed me to perform cut/paste/rename file & folder
actions and even access the top level OS explorer menu within the editor so i
had ,svn,archive,properties and send to

[edit] typo

------
davidlumley
When you mention cursor, I assume you mean caret? Similar to Textmate?

------
baby
> ctrl + T on Windows

doesn't work on my ST2.

~~~
Destroyer661
It's actually Ctrl + P on Windows. I think the author made a typo.

~~~
yen223
It's Cmd + T in Mac OSX, hence the confusion.

------
dr42
Still doesn't seem to have 'correct indentation' which I would use often,
especially for 'data' files like XML or JSON.

~~~
siodine
This is probably obvious for most people, but when you can't find a feature
you want in an editor, you should look for plugins.

So, in this case, you would go to
<http://wbond.net/sublime_packages/community> and search for "indent" or
"pretty" or "xml".

~~~
dr42
Obviously you didn't actually try what you suggested, if you had you'd have
found there are plugins for JSON and XML and probably a few other formats, but
was hoping ST2 would have what textmate and eclipse has had for a long time,
code formatting, java, XML, xsl, JavaScript, c etc.

I know you're new here, but a little reminder about etiquette, even if you
haven't gotten laid in a while, the community here is based on people being
helpful rather than trying to be superior. The problem with that attitude is
that it backfires and just makes you look insecure.

~~~
siodine
Sorry? My response was tailored for your comment -- you didn't mention plugins
and you weren't (and still aren't) clear on the features you're missing. I.e.,
from your comment I inferred that you are new to all this, and so I treated
you as a newcomer. I guess that hurt you feelings? If so, I didn't mean to :)

~~~
dr42
Nope, didn't hurt my feelings at all, I was trying to help you learn the
ropes.

My comment was really pretty clear, and easy to follow, ST doesn't have a code
formatter, you know, like textmate and eclipse do. It's a feature that lets
you take poorly aligned code that is difficult to read, and fix up the
alignment a la K&R et al. Hope that's clear enough for you :)

If you want to find out if someone is a newcomer, you can click on their
profile and see pretty easily.

~~~
Destroyer661
_> I know you're new here_

 _> If you want to find out if someone is a newcomer, you can click on their
profile and see pretty easily._

 _> the community here is based on people being helpful rather than trying to
be superior_

Siodine's account is older than yours. You're rageing on him for trying to
help you out by suggesting you find plugins before dismissing ST2. You're
making an ass of yourself man. Stop acting like an elitist prick.

