As I’ve been writing the Sublime Text Power User book over the last few months, I’ve had some interesting conversations around favourite features of ST. The one feature that I constantly surprise people with is called line bubbling – moving lines of code up and down a document without cutting and pasting them.
It’s an extremely simple feature but will save you lots of time and potentially lost code.
Let’s take this list as a very basic example. This list could be any block of code that you want to move up or down – they are only numbered as a visual.
How do we move them up and down to end up in the correct order? We could cut and paste, but line bubbling is much faster.
In Sublime Text, hold down ⌘ + control (CTRL + SHIFT on Windows) and use your ↑ up* and ↓ down arrow keys to move the lines around. This works for single and multiple lines.
Check out the video for a visual:
Easy! Want to learn more, sign up below and I’ll let you know when my book comes out.
I woke up to a real treat this morning: Sublime Text 3! Sublime Text development has always moved at an incredible pace and now just a few months after 2.0 was released, 3.0 peaks around the corner. ST3 isn’t at the point where it can be your daily editor – you will still be using ST2 for some time – but its exciting to take a look at what ST3 has in store for us!
ST3 is only available to registered ST2 owners, you will be reqired to input your license key upon launch. If you forget where you put your license key, go to Preferences → Browse Packages and then open the settings folder and look for License.sublime_license
What’s new
You can read all the new features over at the Sublime Blog, here are the main features along with some explanation and commentary.
It’s even faster!
Sublime has always been a blazing fast editor and Jon Skinner has outdone himself with this. The editor starts and opens up my last project in less than a second. On OSX the icon doesn’t even reach the top of the bounce before it has loaded.
Python 3.3 & Packages API
Sublime has now switched to Python 3.3. If you aren’t familar, Python is the programming language that Sublime Text uses to expose it’s API. It is how we get all those great packages. Python 3.3 has been out for a while, but many developers have been dragging their heels in upgrading as many of the packages haven’t been ported over. I’m not a Python developer, but according to the Python Wall of Superpowers things are looking better lately.
The downside to this is that most Sublime Text packages will need to be ported to ST2/Python 3.3. The author of Sublime Text says porting to the new API involve minimal work.
Sublime Text package manager doesn’t work yet, but the author Will Bond says work is already underway. Will also has a number of popular packages so I would watch his github, twitter and site for his experiences with porting everything over.
UPDATE: Will Bond has updated package manage to work with Sublime Text 3. See his commend below.
Pane Management
Previously sublime text only allowed you to split your editor into 1-3 columns, 1-3 rows or a grid of 4. This has changed in Sublime Text 3 which exposes controls for splitting panes indefinitely.
I played around with the commands and keyboard shortcuts for a bit but I will be sticking with Origami to manage my panes as I find the commands for moving files splitting panes to be more natural.
Symbol Indexing
ST3 introduces project wide Goto Symbol and Goto Definition. Previously Goto symbol fuzzy search only worked when you specifically noted which file you wanted to look in. In the example above I’m able to see everywhere the post_render function is called in Octopress. This is a really big step up for Sublime that may have a few IDE-lovers jumping ship.
Themes and colour schemes
The UI of Sublime hasn’t changed at all other than a few animations when hiding/showing the sidebar. I’ve tested ST3 with my Cobalt2 theme and color scheme and I’m happy to report that everything worked flawlessly.
Prices
Sublime text 3 will go for $70 or a $30 upgrade from ST2 ($15 if you purchased it recently, so don’t hold off buying ST2). Money extremely well spent.
Wishlist
This is just the beginning of ST3 and I’m excited to see what it has in store for the future. A few things that are on my wishlist:
Full blown terminal integration
Binary file display - One thing Coda does really well. If I click an image, I’m able to preview it and get its dimensions.
Find/Replace Macros – being able to record a find/replace and play it back or run with arguments would be very handy.
Sidebar icons – Sublime excells in its simple interface but having icons for folders/filetypes is something that has always been on my list
What is yours? - Post in the comments what you hope Sublime Text 3 will bring
The Book
Of course all of this information will be in my upcoming book on Sublime Text. I’m making excellent progress and will have a release date for you all soon. Drop your email below and I’ll give you a hoot when it’s launched.
I’m working hard on my Sublime Text Book and have received fantastic response for everything so far – very motivating. The last post was so well received that I’ve decided to post a few more of my favourite tips.
1. Save on focus lost
Chronic ⌘+S’er? This tip is particularly helpful when working with CSS/LESS/SASS and switching between your editor and browser. Instead of saving on every tiny little change, tell Sublime to automatically save your files when you tab away from the editor.
I find this is super handy when working with extensions like Live Reload or compiled languages like coffeescript that watch for file saves. Put this in your settings file at Preferences → Settings - User
"save_on_focus_lost": true
If you work with other watch scripts that break and restart a process upon save (like supervisor or forever), this might not be ideal for you. No problem, only enable it for the languages you want – simply place the above setting in /Packages/User/[syntax].sublime-settings. For example, I put the above in CSS.sublime-settings and LESS.sublime-settings
2. Paste and Indent
One of the best tricks I’ve ever learned in Sublime Text is paste and indent. If you have ever pulled a piece of code off the Internet and pasted it into your application, you’ll no doubt feel the pain of having it paste in all weird and have to go in and fix it.
Easy fix to this, instead of pressing the normal cmd + v to paste, simply switch to using cmd + shift + v to paste. This will automatically indent your code block.
Like that one? I loved it so I remapped my key combos to paste and indent by default on cmd + v
Paste this little snippet into your key bindings file located at Preferences → Key Bindings - User
Now, if for some reason you end up with either a block of code or an entire file filled with hard to ready, messy, poorly indented code, reindent is your best friend.
To automatically re-indent your code, simply select the code you want to indent and then from the menu Edit → Line → Reindent
Sublime doesn’t ship a keyboard shortcut for this. No problem, let’s make our own. Pop this little snippet into the Preferences → Key Bindings - User file.
When making a change in sublime text, by default it changes the × to a circle of the same colour.
Make it a little more obvious when you haven’t saved changes to a document by turning on the following:
"highlight_modified_tabs": true
The exact styling of your modified tabs will vary depending on your theme. It looks fantastic with my cobalt2 theme for Sublime Text
I’m an instructor at HackerYou where we use Sublime Text extensively. This is a small, yet common, problem that we run into. Making it visually obvious cuts down on mistakes like this.
5. Proper Fullscreen for Mac Users
This one is only for those running Sublime Text on Mac OSX 10.7 or 10.8 with multiple monitors. You have probably realized that apple has really dropped the ball when using fullscreen, rendering the rest of multiple monitors into nothing but a linen backdrop.
If you like to code fullscreen yet still use your other monitors, go ahead and add the following to your preferences file:
"use_simple_full_screen": true
You’ll have to restart Sublime Text for this one.
More?
I’ve got plenty more tips as well as in-depth guides on the rest of Sublime Text coming up in my book. If you have a must-use tip or commends on any of the above, please feel free to leave a comment!
I love tweaking Sublime Text. There are hundreds of settings you can change and I’ve blogged about a few of them before.
Here are five visual changes you can use to make your text editor just right. You should place these items inside your User settings file which can be located at preferences → Settings - User
1. Change the caret style
Who thought a caret could be sexy? Change your caret style to phase and it will fade in and out rather than blink.
"caret_style": "phase"
Other available options include “smooth”, “phase”, “blink”, “wide” and “solid”. I’ve been fond of “wide” which doesn’t blink and is clearly visible for screenshots in my new book.
2. Highlight current Line
This is one thing I wish Sublime Text enabled by default. Highlighting the current line is a subtle visual cue when jumping back and forth between a browser and code.
This is also super handy when you are dealing with long lines of code/text and you want to quickly know if the current line is wrapped or not.
"highlight_line": true
3. Increase the line height
This trick adds just two pixels to each line, but increases the readability of code so much better. Might not be for everyone but I really enjoy this one.
"line_padding_bottom": 1,
"line_padding_top": 1
4. Show Code folding arrows
Code Folding in Sublime Text is really great but I’ve noticed most people don’t use it as much as they do in editors because the arrows aren’t visible until you hover over the gutter.
Make them always visible and get folding!
"fade_fold_buttons": false
5. Bold Folder Labels
One of the downsides to Sublime Text is that the sidebar isn’t as strong as other editors. One visual cue that helps me out is bolding folders. This helps me quickly identify what is a folder and what is a file.
"bold_folder_labels": true
More…
I’ve got plenty more in a book I’m writing about Sublime Text. If you are interested in improving your text editor productivity, please sign up below and I’ll give you a hoot when it goes live!
I love huge text editor colour schemes. I’ve tried dozens of them over the years but always found myself coming back to trusty old cobalt. I liked this theme quite a but but I didn’t love it. So, over the years I’ve tweaked and tuned cobalt into a theme that I am very happy with. Its easy on the eyes, works well across many langages and takes note of those little UI elements like the caret, searches and bracket matching.
I have had quite a few friends use my theme and they seem to be sticking with it. So, I’ve decided to release it to the masses. To download it, head on over to the github repo. As always, would love to hear any feedback you may have
Quick aside: I’m in the process of writing a book about Sublime Text. If you are interested in improving your text editor productivity, please sign up below and I’ll give you a hoot when it goes live.
cobalt2
A Sublime Text theme based on our old blue friend cobalt.
A refined colour scheme that is easy on the eyes and takes small UI elements into account. Includes full sublime theme (sidebar, search, tabs, etc…).
See below for examples.
Installation
Installation is easy, just follow these steps:
1. Open your Sublime Text packages directory Preferences → Browse Packages
1. Drop in the Theme - Cobalt2 directory here (Right into /Preferences/)
1. Lastly, open Preferences → Settings - User. Add the following two lines:
To continue on with my string of blog posts on Sublime Text 2, I’m going to show you a short but handy feature that was just pushed to the stable build. Code Folding!
Unfortunately, collapsing of code in sublime text isn’t exactly the same as textmate, so you dont get the little arrows in the sidebar. The code is also folded into a single character which makes it easy to delete an entire block of folded code without noticing you have done so. This is the first iteration of code folding in sublime text 2, so I’m sure it will only get better. With those cautions in mind lets take a look at how to work code folding in Sublime. Continue reading →
A really great feature of Sublime Text 2 is the ability to create your own build scripts. A build script is helpful when you are writing in a language that needs to be compiled or executed from terminal / command line. I personally use build scripts to compile the current file into CoffeeScript as well as run the current file in Node JS.
Watch the tutorial or continue reading to learn how to make Sublime Text 2 build scripts. Continue reading →
I’m a long time Coda user. A few months ago I, like everyone else, decided to switch over to vim. I really liked Vim but just couldn’t get the hang of it for whatever reason. After shamefully crawling back to Coda, I found myself realizing that Coda fell short in a few areas. It was then I decided to give Sublime Text 2 a shot as it had been touted as the sucessor to Text Mate. Its taken me a few weeks to get used to, but I can happily say I’m a Sublime Text 2 user now. Here are a few tips that make switching over easier.