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 eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

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 : 9781849698436
Concepts :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Dec 24, 2013
Length: 110 pages
Edition : 1st
Language : English
ISBN-13 : 9781849698436
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

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.