Join Kevin Yank for an in-depth discussion in this video Changing preferences, part of Learning Sublime Text 3.
- [Voiceover] Sublime Text sometimes gets a bit of a bad rap for not having a nice graphical user interface for controlling all of its settings, but the system of text files it uses to control all of your settings is uniquely flexible, and I'd like to show it to you now. If you go to the Sublime Text menu on your Mac, or on Windows choose the preferences menu from the top of the window, you can find the menu item "Settings" underneath there. And when you select that, you get this new split pane window. On the left is all of the preferences that Sublime Text provides, and on the right is an empty user preferences file.
Now you might be tempted to come over here on the left and try to modify one of these values, but when you do you'll find it's read only. You can't change anything in this file. This file represents the factory defaults that come built in to Sublime Text, and these might get updated when new versions of the editor come out, and so this isn't a great place to put your own personal preferences. That's why Sublime provides a separate file for your user preferences. And so what you can do is use the left hand panel as a reference for what is available, and you can copy and paste settings into the space between the braces here on the right.
It tolerates that trailing comma just fine, and I actually like to leave it there, because it makes it a little easier to add new settings after this line in future. Now that's how you'll be controlling most settings in Sublime Text, but there are a couple of settings that Sublime Text knows you're going to want to change more often, and it provides menu items for those. On the preferences menu, you'll find the font submenu, which contains "larger" and "smaller" options, and if I choose "larger", you can see my typeface immediately gets bigger in the editor, and that's because Sublime Text has gone in and edited my user preferences for me automatically and added this font size settings with a value of 13.
That menu also contains keyboard shortcuts for controlling this setting, and if I hit command minus or control minus on Windows, and command plus or control plus on Windows, I can reduce and increase the font size, and you can see, as I go, Sublime Text is updating this file for me on the fly. I don't have to have this file open in order to change this setting, even if it's closed, Sublime Text will go in and update it silently in the background for me. You'll also notice that trailing comma and the helpful comment that was at the top of the file have disappeared, and that's because when Sublime Text rewrites your user preferences for you, it writes the simplest possible version of it that will give you the settings you want.
But that's okay, the file is still plenty easy to read. I'm going to setting on a font size of sixteen points here to make my typeface nice and big for you for the rest of this course. When you're don't adjusting settings, you can close this window and go back to what you were working on. Now, this CSS file is looking nice and readable with my large typeface, but let's say I switch to my "index.htm" file here and I find that it's a little crowded. Maybe the typeface is a little to big for me. Well, Sublime Text let's you control settings for individual file types.
Just go back to that preferences menu, and you'll find "Settings - Syntax Specific". If I select this, I'll get that split window again with all of my default settings on the left, and this time on the right, I'm looking at my "html.sublime-settings" file. And this is a file that contains settings that will override not only the factory defaults on the left, but also my user preferences file that I was just editing before. But this file will only apply to HTML files that I open in my editor.
So if I set a font size of twelve points here and save my changes, you'll see that nothing happens to the files open in this window because they're not HTML files. But if I close this window, my "index.htm" file does have a smaller typeface than it did before, as compared to my CSS file here. So that's how you control settings for individual file types. If you want to get a look at all of the settings files that you have for your editor, you can go to the browse packages menu item here.
This will open Sublime Text's packages folder, which contains a user folder for all of your user preferences. If you open this folder, you'll see right now I have these two files: My general user preferences file, and the HTML sublime settings file that applies to just HTML files. And if I go ahead and delete this file, you'll see in the background "index.htm" immediately returns to the standard font size that I've specified in my preferences sublime settings file.
The last place you can put settings is in a project. When we created this roux website project, I suggested this roux website sublime project file was a good thing to check into version control. And that's because it let's you share settings among the members of your team. If I open this file, you'll see right now, all it contains is the list of folders that are present in my project, with this dot referring to the current folder. But I can add a new section to this file, called settings, and this is a place that I can specify settings that will apply to all of the files in this project.
One of the things that you might want to put here is your indentation settings. Let's say my team and I have agreed that we're going to use two spaces for indenting in all of the files in this project. Well, I can type tab size two, and translate tabs to spaces true. And you can see when I save this, I'll go from a tab size of four down to two in this current file, and if I go into my project folder and create a new file in it, you can see in the status bar here, it is using two spaces for indenting, whereas if I close my project, and then create a new file, it will still get created with my global settings, a tab size of four.
So these project specific settings are a great way to keep you and your team in sync, and if you collaborate with different teams on different projects throughout the day, project specific settings give you a way to comfortably manage the different settings that those different teams might be using. So yeah, this cascading system of text files to control the settings in your editor is not as easy as a nice easy as a nice simple graphical user interface, but it is really powerful, and that's just what you want out of a power tool like Sublime Text 3.
Instructor Kevin Yank takes students through the basic, not-so-basic, and downright hidden features of the editor, demonstrating how to use each tool and command to become more productive. Find out how to find and replace sections of code, bookmark your position, leverage helpful shortcuts, edit multiple lines of code simultaneously, and automate some of your work with autocompletion, snippets, and macros. Plus, learn how to tweak the appearance and configuration to make Sublime Text work best for you.
- Juggling multiple files
- Managing files and settings across multiple projects
- Finding and replacing text
- Customizing the look and feel
- Using multiple selections to edit multiple lines and large amounts of text
- Autocompleting code
- Using snippets and macros
- Extending Sublime Text with packages