Tags

, , , , , , ,

I don’t know about you but I use multiple machines throughout my day and like to have Sublime Text setup on each. I also don’t want to have to manually keep each instance in sync as I change configuration or add a new plug-in.

In this article I will layout how to setup Sublime Text on multiple machines and keep any changes you make automatically synced up.

On the choice of tools

I will be using OneDrive (previously SkyDrive) to accomplish this but you can accomplish the same result using DropBox or the like. I have also included a reference to a related article at the end of this post describing just that.

Also, I am a fan of the console and command line tools. In this article I will be utilizing Chocolatey to install Sublime Text. If you prefer to download and install the applications manually it will not effect the rest of the article.

Installation & Setup

Okay, let’s get to it! The first machine you setup will create the shared location and then each additional machine will just reuse that existing location.

On the first machine

1. Install Sublime Text 3

cinst SublimeText3

2. Run Sublime Text 3.

3. Download & install Package Control for Sublime Text 3 according to the instructions.

4. Shutdown Sublime Text

5. Setup a sync to a shared location for Sublime Text 3 settings. These commands will move the default installed user settings folder to your shared location and then setup a symlink back to the original location so Sublime Text can find the settings.

cd "%appdata%\Sublime Text 3\Packages\"
mkdir "%userprofile%\SkyDrive\Sublime Text 3"
mv User "%userprofile%\SkyDrive\Sublime Text 3\"
mklink /D User "%userprofile%\SkyDrive\Sublime Text 3\User"

note: You need to use a command window with administrative rights
note: Change the paths to match your environment

At this point you have completed the basic setup and moved your user settings for Sublime Text to your shared location. Any changes you make to Sublime Text now will be synced to your shared location.

On all other machines

1. Install Sublime Text 3

cinst SublimeText3

2. Run Sublime Text 3.

3. Download & install Package Control for Sublime Text 3 according to the instructions.

4. Shutdown Sublime Text

5. Setup a sync from your shared location to your machine for your Sublime Text 3 settings. These commands will delete the default installed user settings folder and then setup a symlink from your shared location to the original location so Sublime Text can find the settings.

cd "%appdata%\Sublime Text 3\Packages\"
rm -r User
mklink /D User "%userprofile%\SkyDrive\Sublime Text 3\User"

note: You need to use a command window with administrative rights
note: Change the paths to match your environment

6. Run Sublime Text 3.

Now when you make any changes to your settings, installed packages and the like it will save to your shared location. Each machine will be automatically updated and when you load up Sublime Text 3 on these machines they will be automatically updated to the same state.

At this point you are good to go and all your changes will be synced up. Next I will walk through setting up the Sublime Text package control.

Installing a package with Package Manager in Sublime Text 3

1. Launch the Command Palette with Ctrl+Shift+P

2. Type “Install Package” or “ip” (the first letter of each word) for short, and hit enter.

3. Type the name of the package you want to install, for example, “Theme – Soda”. Again, you can use short form here to minimize the typing if you please (ie: tso)

4. Repeat the process for any and all packages that interest you.

The packages you install will be registered in your “Package Control.sublime-settings” file. Since this file is located in your shared folder it will be automatically synced to all your other machines. As soon as you load up Sublime Text on these machines, it will detect the changes and install the packages.

At the time of this post, I currently use the following Sublime Text 3 packages:

  • Theme – Soda: A really nice theme for Sublime Text. It has both a light and a dark theme. I am a fan of the dark myself.
  • Vintageous: provides better vi/vim support & is updated more frequently than the built in Vintage package
  • Emmit (previously Zen Coding): allows you to build HTML quickly and easily
  • SideBarEnhancements: adds numerous useful enhancements to the Sublime Text folder sidebar

Install & Configure Source Code Pro Fonts

I use a custom font in Sublime Text called Source Code Pro. I really like the way it looks for code. If you would like to give it a go, here are the steps.

1. Download and install the Source Code Pro fonts.

2. Launch the Command Palette with Ctrl+Shift+P

3. Open your “Preferences: Settings User” (type “psu” for short)

4. Add or update the “font_face” setting to “Source Code Pro”

"font_face": "Source Code Pro",

5. Save the file (you might need to restart Sublime Text to apply the changes)

Configure Your Preferences

And finally it is time to setup your personal preferences for Sublime Text. This is done in the user “Preferences.sublime-settings” file. To open and modify it:

1. Launch the Command Palette with Ctrl+Shift+P

2. Open the “Preferences: Settings – User” option (type “psu” for short)

3. Modify the settings to fit your preferences

As an example, here is a look at my preferences (at the time of this writting):

{
	"auto_complete_delay": 500,
	"color_scheme": "Packages/Color Scheme - Default/Pastels on Dark.tmTheme",
	"detect_indentation": false,
	"detect_slow_plugins": false,
	"dictionary": "Packages/Language - English/en_GB.dic",
	"file_exclude_patterns":
	[
		"*.pyc",
		"*.pyo",
		"*.exe",
		"*.dll",
		"*.obj",
		"*.o",
		"*.a",
		"*.lib",
		"*.so",
		"*.dylib",
		"*.ncb",
		"*.sdf",
		"*.suo",
		"*.pdb",
		"*.idb",
		".DS_Store",
		"*.class",
		"*.psd",
		"*.db"
	],
	"folder_exclude_patterns":
	[
		".svn",
		".git",
		".hg",
		"CVS"
	],
	"font_face": "Source Code Pro",
	"hot_exit": false,
	"ignored_packages":
	[
		"Vintage"
	],
	"remember_open_files": false,
	"soda_classic_tabs": true,
	"tab_size": 4,
	"theme": "Soda Dark.sublime-theme",
	"translate_tabs_to_spaces": true,
	"trim_automatic_white_space": true,
	"trim_trailing_white_space_on_save": true
}

For more information on the user settings file, see the Sublime Text documentation

Some references that I used when writing this article:

Advertisements