Mastering Sublime Text A concise guide to help you master the Sublime Text skills, from basic setup through the art of theme customization to the proficiency of plugin development Dan Peleg BIRMINGHAM - MUMBAI Mastering Sublime Text Copyright © 2013 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: December 2013 Production Reference: 1171213 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-84969-842-9 www.packtpub.com Cover Image by Gagandeep Sharma ([email protected]) Credits Author Copy Editors Dan Peleg Roshni Banerjee Tanvi Gaitonde Reviewers Mradula Hegde James Brooks Dipti Kapadia Dougal Matthews Insiya Morbiwala Matt Morrison Deepa Nambiar Jeffrey Sadeli Alfida Paiva Shambhavi Pai Acquisition Editors Kevin Colaco Project Coordinator Llewellyn Rozario Jomin Varghese Lead Technical Editor Indexer Larissa Pinto Hemangini Bari Technical Editors Production Coordinator Gauri Dasgupta Nilesh Bambardekar Monica John Cover Work Proofreader Nilesh Bambardekar Dan McMahon About the Author Dan Peleg is an accomplished software engineer. As a former developer in the Israeli Intelligence Force, he holds extensive experience in both defense and robotic industries, and has previously lectured at DefCon conventions. Dan has developed unique algorithms for robotic platforms, specializes in a variety of software platforms, and currently works as the CTO for an American startup company. I want to thank every plugin developer whose plugin is mentioned in this book. I would also like to thank Stuart Herbert for the content on PHPUnit, and Tom Lahat and Yali Saar for their support. About the Reviewers James Brooks has been programming for over a decade, starting out at the age of seven. He's worked his way through multiple languages from LOGO to C++ and back again. Having built a custom operating system and several half-baked games, he's now settled into web development. He is currently working at Blue Bay Travel. Dougal Matthews is a Python developer based in Scotland. He works for Red Hat, where he helps out with OpenStack. Dougal is also involved in running a number of community events, groups, and conferences. Matt Morrison, after trying every development environment available, discovered Sublime Text, and never looked back. He immediately fell in love with its emphasis on text-based configuration files, accessibility of Python API, and vibrant ecosystem of plugins and extensions contributed by the community. Being a tinkerer and a teacher at heart, Matt set about learning as much as he could about the software and sharing his knowledge and passion with others on StackOverflow, the Sublime forums, and elsewhere. He has authored two extensions on Package Control: the Neon Color Scheme, which aims to make as many languages look as good as possible; and Python Improved, a better Python language definition that fixes bugs in the original as well as introducing new features, including Django integration, IPython support in SublimeREPL, Python 3 function annotations, and more. He is also an active contributor of bug fixes and feature improvements for a number of other open source projects. Despite his broad interests in all things computer-related, software development is only a (rather time-consuming) hobby. Matt received his Master's degree in Molecular Medicine from Penn State in 2005, and is employed as a scientist in his day job, working on cell and molecular biology. He is currently working in Biotech in the greater Boston area, and absolutely loves what he does. Matt has a blog about Sublime Text at http://mattdmo.com, and invites one and all to stop by and participate. You can find him on GitHub, StackOverflow, and Twitter as MattDMo. I would like to thank my wife Amy and my two little boys for their support and understanding. Jeffrey Sadeli graduated from Rose-Hulman Institute of Technology in 2008 with a bachelor's degree in Computer Science. As a technology and design enthusiast, his passion lies in applying elegant technical solutions and beautiful designs to solve problems. Having worked for several years as a full-time software development engineer at Beckman Coulter developing automation applications, he is currently pursuing a master's degree in Business at Doshisha University. www.PacktPub.com Support files, eBooks, discount offers and more You might want to visit www.PacktPub.com for support files and downloads related to your book. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub. com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. TM http://PacktLib.PacktPub.com Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books. Why Subscribe? • Fully searchable across every book published by Packt • Copy and paste, print and bookmark content • On demand and accessible via web browser Free Access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access. Table of Contents Preface 1 Chapter 1: Installing Sublime Text 5 Preparing for Sublime Text Installation 5 Installing Sublime Text on OS X 6 Working with Sublime CLI 6 Installing Sublime Text on Windows 32/64 bit 7 Adding Sublime to the environment 8 Installing Sublime Text on Linux 9 Installing Sublime Text on Ubuntu 32/64 bit 9 Setting Sublime Text as the default editor 10 Installing Sublime Text on other Linux distributions 10 Adding a desktop file 11 Getting to know the Data and Packages directories 12 The Data directory 12 The Packages directory 12 Delving into packages, plugins, snippets, and macros 13 Running Sublime for the first time 14 Simple navigation 15 Sublime's command palette 16 The Python console 17 Installing the Package Control ASAP 18 Summary 19 Chapter 2: Code Editing 21 Discovering Search and Replace 21 Regular Expressions 22 Search and Replace – a single file 22