TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Some things beginners might not know about Sublime Text

226 pointsby ashamedlionalmost 13 years ago

34 comments

poalmost 13 years ago
Also a must-have: Sublime Package Control<p><a href="http://wbond.net/sublime_packages/package_control" rel="nofollow">http://wbond.net/sublime_packages/package_control</a><p>Useful for installing things like themes, syntax awareness, code linters, etc...
评论 #4247566 未加载
JonnieCachealmost 13 years ago
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...<p>EDIT: Just for fun, here is that file on OS X: <a href="https://gist.github.com/3117613" rel="nofollow">https://gist.github.com/3117613</a> 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.<p>Sublime is great. It reminds me of a less insane version of Foobar2000.
评论 #4247547 未加载
评论 #4252064 未加载
评论 #4247646 未加载
siodinealmost 13 years ago
Ctrl+Alt+P to get a dialog for opening all your Sublime projects.<p>Ctrl+R for navigating to functions or classes within the current file.<p>SublimeClang gives you Visual Studio-style Intellisense, static analysis, and jump to definition/implementation.<p>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.<p>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} } ]
hebejebelusalmost 13 years ago
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.<p>(This is in ST2 for Mac OS X - I'm sure there's an equivalent feature in ST2 for other systems.)
评论 #4246841 未加载
评论 #4246968 未加载
haastedalmost 13 years ago
Cmd + d selects the current word.<p>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.
评论 #4247022 未加载
评论 #4247067 未加载
评论 #4247244 未加载
评论 #4249390 未加载
Osmosealmost 13 years ago
Cmd-P is useful for opening existing files, but what's the preferred way for creating them?<p>I eventually had to get an extension and modify it to replicate emacs' c-x c-f to create files.
评论 #4247191 未加载
评论 #4247215 未加载
mefalmost 13 years ago
One of my favorite features is the flexibility of the Goto Anything dialog (CMD+T or CMD+P) e.g.:<p>- Goto file: "con pos" -&#62; app/controllers/posts_controller.rb<p>- Goto line in file: "con pos:100" -&#62; app/controllers/posts_controller.rb line 100<p>- Goto function in file: "con pos@foo" function foo in app/controllers/posts_controller.rb<p>Also one that came up recently is CMD+ALT+Q to auto-wrap long comments to your ruler (e.g. 80 columns).
评论 #4247135 未加载
Tloewaldalmost 13 years ago
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.
评论 #4247054 未加载
toran1302almost 13 years ago
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.<p>A fine grained find+replace/modify :)
draftablealmost 13 years ago
You can also move the curent line up and down the page using Ctrl + Cmd + Up/Down
评论 #4246934 未加载
评论 #4247238 未加载
LocalPCGuyalmost 13 years ago
For those that like/need to print their code, there is a plugin that does that: <a href="https://github.com/joelpt/sublimetext-print-to-html" rel="nofollow">https://github.com/joelpt/sublimetext-print-to-html</a>
Dunkirkalmost 13 years ago
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.
评论 #4248057 未加载
评论 #4247639 未加载
评论 #4248014 未加载
mixmastamykalmost 13 years ago
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.<p>- Code folding: No fold level 1 option, would like a hotkey. No line at the fold, just an icon at end of line.<p>- 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.<p>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.<p>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.
评论 #4247630 未加载
ohgodthecat3almost 13 years ago
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)
nottombrownalmost 13 years ago
Cmd-Shift-P is incredibly useful. It lets you intelligently search all the commands.<p>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.
eogasalmost 13 years ago
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.
JulianMorrisonalmost 13 years ago
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.
dt7almost 13 years ago
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).
aviraldgalmost 13 years ago
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.
评论 #4249712 未加载
pastralmost 13 years ago
For more ST keyboard shortcuts: <a href="https://gist.github.com/1736542" rel="nofollow">https://gist.github.com/1736542</a>
noivalmost 13 years ago
Despite ST2 is great and everyday there is a new surprising feature to detect - what is the shortcut for 'save all'?
评论 #4247265 未加载
评论 #4247346 未加载
rockzapperalmost 13 years ago
The shortcut to quickly open Files is Ctrl + P (or Cmd + P on Mac) as opposed to Ctrl + T mentioned in the article.
draftablealmost 13 years ago
To quickly get multiple cursors on many lines at once, you can also select what you need and hit Cmd + Shift + L
tixzdkalmost 13 years ago
I've kept my favorite shortcuts open in a panel for about a week, so I could learn them by heart: <a href="http://pastebin.com/hQtYKzhN" rel="nofollow">http://pastebin.com/hQtYKzhN</a> Favorites include: Expand selection (to various levels), close tag, block commenting and splitting lines!
madpropsalmost 13 years ago
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).<p>ctrl + m when in a bracket sets the cursor to it's matching bracket.<p>ctrl + up or ctrl + down scrolls the document up or down.<p>ctrl + g goes to a line.
taylorbuleyalmost 13 years ago
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.
评论 #4246995 未加载
评论 #4248226 未加载
B-Scanalmost 13 years ago
Ctrl+Shift+D duplicates line
misealmost 13 years ago
Here's a (PC-oriented) cheat sheet of some keyboard shortcuts:<p><a href="https://gist.github.com/1958143" rel="nofollow">https://gist.github.com/1958143</a>
treboralmost 13 years ago
CMD/CTRL + R will take you immediately to the find by symbol/definition. This is the same as CMD/CTRL + P and then typing @.
deviartealmost 13 years ago
I am pretty sure that "Quick file opening" is CTRL+P on Windows. Since CTRL+T opens a new tab for me..
评论 #4246940 未加载
评论 #4247180 未加载
prisonguardalmost 13 years ago
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 &#38; folder actions and even access the top level OS explorer menu within the editor so i had ,svn,archive,properties and send to<p>[edit] typo
davidlumleyalmost 13 years ago
When you mention cursor, I assume you mean caret? Similar to Textmate?
babyalmost 13 years ago
&#62; ctrl + T on Windows<p>doesn't work on my ST2.
评论 #4248048 未加载
dr42almost 13 years ago
Still doesn't seem to have 'correct indentation' which I would use often, especially for 'data' files like XML or JSON.
评论 #4247078 未加载