Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Mastering Sublime Text
Mastering Sublime Text

Mastering Sublime Text: When it comes to cross-platform text and source code editing, Sublime Text has few rivals. This book will teach you all its great features and help you develop and publish plugins. A brilliantly inclusive guide.

eBook
€13.98 €19.99
Paperback
€24.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Mastering Sublime Text

Chapter 2. Code Editing

This chapter will guide us from Sublime's basic features to its most advanced ones, and explore techniques to use while editing code. We will also install two important plugins for most languages and master Sublime's Shortcuts Map.

In this chapter we will cover the following topics:

  • Discovering Search and Replace

  • Mastering Column and Multiple Selection

  • Navigating through Project, Files, and Classes

  • Using the must-have SublimeCodeIntel

  • Linting with SublimeLinter

  • The must-know Shortcuts Map

Discovering Search and Replace


Search and Replace is one of the common actions for any text editor. Sublime Text has two main search features:

  • Single file

  • Multiple files

Before covering these topics, let's talk about the best tool available for searching text and especially, patterns; namely, Regular Expressions.

Regular Expressions

Regular Expressions can find complex patterns in text. To take full advantage of the Search and Replace features of Sublime, you should at least know the basics of Regular Expressions, also known as regex or regexp. Regular Expressions can be really annoying, painful, and joyful at the same time!

We won't cover Regular Expressions in this book because it's an endless topic. We will only note that Sublime Text uses the Boost's Perl Syntax for Regular Expressions; this can be found at

Tip

I recommend going to http://www.regular-expressions.info/quickstart.html if you are not familiar with Regular Expressions.

Search and Replace – a single file

Let's open the Search panel...

Mastering Column and Multiple Selection


Multiple Selections is one of Sublime's coolest features; TextMate users might be familiar with it. So how can we select multiple lines? We select one line like we usually do and select the second line while holding Ctrl or command on OS X. We can also subtract a line by holding the Alt key or command + Shift keys on OS X. This feature is really useful and it is recommended that you play with it. The following are some shortcuts that can help us feel more comfortable with multiple selections:

Multiple selection action

Windows/Linux

OS X

Return to Single Selection Mode

Esc

Esc

Undo last selection motion

Ctrl + U

command + U

Add next occurrence of selected text to selection

Ctrl + D

command + D

Add all occurrences of selected text to selection

Alt + F3

Control + command + G

Turn Single Linear Selection into Block Selection

Ctrl + Shift + L

Shift + command + L

Column Selection

The Column Selection feature is one of...

Navigating through everything


Sublime is known for its ability to quickly move between and around files and lines. In this section, we are going to master how to navigate our code quickly and easily.

Go To Anything

We already learned how to use the Go To Anything feature, but it can do more than just searching for filenames. We can conduct a fuzzy search inside a "fuzzily found" file. Really? Yeah, we can. For example, we can type the following inside the Go To Anything window:

isl#wld

This will make Sublime perform a fuzzy search for wld inside the file that we found by fuzzy searching isl; it can thus find the word world inside a file named island.

We can also perform a fuzzy search in the current file by pressing Ctrl +; in Windows or Linux and command + P, # in OS X. It is very common to use fuzzy search inside HTML files because it immediately shows all the elements and classes that match, accelerating navigation.

Symbol search

Sometimes we want to search for a specific function or class...

Using the must-have SublimeCodeIntel


SublimeCodeIntel is a must-have plugin. Its main features are:

  • The Jump to Symbol Definition feature, which allows a user to jump to the file and line of the defining symbol

  • It Imports autocomplete and displays the available modules/symbols in real time

  • The Function Call tooltips display information in the status bar about the working function

Installing SublimeCodeIntel

We can easily install this plugin using the Package Control utility that we installed earlier. Let's open it up by pressing Ctrl + Shift + P in Windows or Linux and command + Shift + P in OS X. Choose Install Package and install the SublimeCodeIntel plugin. We will then need to restart Sublime.

When it first starts, SublimeCodeIntel needs to build an index of the languages you're using. Depending on the number of modules/libraries you have installed and the size and complexity of the project you're working on, this can take some time. Be patient though, it will be well worth it when it's ready...

Linting with SublimeLinter


Linting is a term for flagging suspicious and non-portable constructs, likely to be bugs in any written language. SublimeLinter is a plugin that supports linting and has the following linters built in:

  • C/C++: This lints via cppcheck

  • CoffeeScript: This lints via coffee –s –l

  • CSS: This lints via built-in csslint

  • Haml: This checks syntax via haml –c

  • HTML: This lints via tidy

  • Java: This lints via javac –Xlint

  • JavaScript: This lints via built in jshint, jslint, or gjslint (if installed)

  • Lua: This checks syntax via luac

  • Objective-J: This lints via built in capp_lint

  • Perl: This lints via Perl::Critic or syntax and deprecation check via perl-c

  • PHP: This checks syntax via php –l

  • Puppet: This checks syntax via puppet parser validate

  • Python: This is a native, moderately-complete lint

  • Ruby: This checks syntax via ruby –wc

  • XML: This lints via xmllint

Installing SublimeLinter

We can install this plugin by using the Package Control that we installed earlier. Let's...

The must-know shortcuts map


The following is a must-know shortcuts map for Sublime Text:

General

General shortcuts for Sublime's basic features are as follows:

Command

Windows/Linux

OS X

Open the command palette

Ctrl + Shift + P

command + Shift + P

Toggle Side Bar

Ctrl + KB

command + KB

Show scope in status bar

Ctrl + Shift + Alt + P

Control + Shift + P

Python Console

Ctrl + `

Control + `

New Window

Ctrl + Shift + N

command + Shift + N

Tabs

Shortcuts to control tabbing in Sublime:

Command

Windows/Linux

OS X

New Tab

Ctrl + N

command + N

Close Tab

Ctrl + W

command + W

Open last closed Tab

Ctrl + Shift + T

command + Shift + T

Next Tab

Ctrl + Tab

Control + Tab

Previous Tab

Ctrl + Shift+Tab

Control + Shift + Tab

Bookmarks

Bookmarks are similar to the favorites option while surfing in the Web; we can toggle bookmarks on lines and then jump between them. Here are the shortcuts for using Bookmarks:

Command

Windows/Linux

OS X

...

Summary


By now we should have mastered code editing and keyboard shortcuts; we can now work on any project in any language with the help of Lint and Code Intelligence.

It is important to know that SublimeLinter and SublimeCodeIntel do not support all kinds of projects and languages. They are also not the right choice for you if you are developing in a specific language; there may be a plugin that fits your requirement better. In the next chapter we are going to learn what Snippets, Macros, and Key Bindings are, and even make our own snippet!

Left arrow icon Right arrow icon

Key benefits

  • Discover efficient, keyboard-driven text editing
  • Recognize the latest build of Sublime Text 3
  • Full of illustrations and diagrams, with clear, step-by-step instructions and practical examples that will help you in building cross-platform applications using Sublime Text

Description

Sublime is the leading platform for developing websites, applications, and software. Sublime Text is a sophisticated, cross-platform text and source code editor. It supports a number of different programming languages and is extremely efficient and feature rich. With Sublime Text, programmers can develop their web applications faster and with more efficiency. This book will put you at the frontier of modern software development. It will teach you how to leverage Sublime for anything from mobile games to missile protection. Above all, this book will help you harness the power of other Sublime users and always stay on top. This book will show you how to get started, from basic installation through lightning fast code navigation and up to the development of your own plugins. It takes you from the early stages of navigating through the platform and moves on by teaching you how to fully customize your platform, test, debug, and eventually create and share your own plugins to help and lead this community forward. The book will then teach you how to efficiently edit text, primarily by using the keyboard. You will learn how to interact with the Sublime Text community using the mailing lists and IRC.

Who is this book for?

This book is for developers with experience in any type of programming language, and for those who want to start using Sublime Text or perfect their existing skills. No knowledge of Sublime Text or any other code editor or IDE is expected.

What you will learn

  • Understand the concepts of advanced search and replace techniques
  • Exercise the use of Code Intelligence in Sublime
  • Apply and control live Linting in Sublime
  • Discover overriding and maintaining key shortcuts
  • Learn to test and debug PHP, JavaScript, Python, and Ruby code using Sublime
  • Develop plugins and publish them

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Dec 24, 2013
Length: 110 pages
Edition : 1st
Language : English
ISBN-13 : 9781849698429
Concepts :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Dec 24, 2013
Length: 110 pages
Edition : 1st
Language : English
ISBN-13 : 9781849698429
Concepts :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 66.98
Mastering Node.js
€41.99
Mastering Sublime Text
€24.99
Total 66.98 Stars icon

Table of Contents

8 Chapters
Installing Sublime Text Chevron down icon Chevron up icon
Code Editing Chevron down icon Chevron up icon
Snippets, Macros, and Key Bindings Chevron down icon Chevron up icon
Customization and Theme Development Chevron down icon Chevron up icon
Unravelling Vintage Mode Chevron down icon Chevron up icon
Testing Using Sublime Chevron down icon Chevron up icon
Debugging Using Sublime Chevron down icon Chevron up icon
Developing Your Own Plugin Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.5
(12 Ratings)
5 star 41.7%
4 star 8.3%
3 star 25%
2 star 8.3%
1 star 16.7%
Filter icon Filter
Top Reviews

Filter reviews by




Ernest C. Liedtke Nov 10, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Excellent book.
Amazon Verified review Amazon
mac champion Jan 22, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The information inside is nothing you can't find with Google, but its organization and the tips it contains really open your mind to how configurable and powerful Sublime Text really is.
Amazon Verified review Amazon
Parsa E. Nov 06, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
i love it
Amazon Verified review Amazon
Chris Thackrey Jun 06, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Nothing you can't find online (free video series on Udemy that covers all the content with more depth.) But this book makes a great cliffnotes for SublimeText enthusiasts that want to become more efficient. I'd buy it again.
Amazon Verified review Amazon
D Sep 28, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Awesome book ! recommended.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.