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
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Sublime Text

You're reading from   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.

Arrow left icon
Product type Paperback
Published in Dec 2013
Publisher Packt
ISBN-13 9781849698429
Length 110 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Dan Peleg Dan Peleg
Author Profile Icon Dan Peleg
Dan Peleg
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Mastering Sublime Text
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Installing Sublime Text FREE CHAPTER 2. Code Editing 3. Snippets, Macros, and Key Bindings 4. Customization and Theme Development 5. Unravelling Vintage Mode 6. Testing Using Sublime 7. Debugging Using Sublime 8. Developing Your Own Plugin Index

Running Sublime for the first time


Open a random code project. We can do it by typing the following command:

subl projectfolder

In the preceding command, projectfolder is the path of the folder we wish to open. We can also open an empty Sublime window and drag the desired folder into it. The Sublime window is shown in the following screenshot:

In the preceding screenshot, on the left-hand side we can see the File Navigator side bar that contains all the open folders in a hierarchy. At the top, we can see the tabs that are currently open, with the selected one highlighted. On the right-hand side, we can see the Mini Map. In Sublime 3, the Mini Map viewport that indicates the current position in the file has been removed. Let's bring it back!

Press Ctrl + O and open the user preferences, or go to Preferences | Settings-User. As you probably noticed, the file is written in the JSON format.

Tip

If you are not familiar with JSON, please go to http://en.wikipedia.org/wiki/JSON#Data_types.2C_syntax_and_example or http://JSON.org.

We need to add the following key value to the file:

"always_show_minimap_viewport": true,

Press Ctrl + S to save. Our file should now look like the following:

{
   "font_size": 14,
   "always_show_minimap_viewport": true,
   "ignored_packages":
   [
      "Vintage"
   ]
}

Because Sublime parses things as soon as they get saved, we should be able to see the Mini Map viewport immediately!

Simple navigation

Let's go back to our file using Goto Anything (shown in the following screenshot), one of Sublime's best features, by pressing Ctrl + P:

Tip

We can even highlight the Mini Map by setting "draw_minimap_border": true in our settings file.

As you can see, the Go To window opens after indexing all files that are on the side bar. We can navigate by typing the file name, acronyms, extension, or prefix.

This search feature is called Fuzzy Text Search or Approximate string matching.

Press Esc to close the Go To window. We are going to use this a lot while developing a large project, so we should feel comfortable with it before moving on.

Try closing the current tab by pressing Ctrl + W. Now if no tab is left open, you can open a new one by pressing Ctrl + N, or even open a new window by pressing Ctrl + Shift + N.

Note

If you press Ctrl + W on Windows or Linux when no tabs are open, the window itself will close.

To jump between open tabs in Windows or Linux, simply press Alt + # (where # is the sequential number of the tab from left to right), or press Command + # for OS X. In Windows or Linux, we can also go to the Next or Previous tab by pressing Ctrl + PageUp and Ctrl + PageDown respectively. The same can be done by pressing Option + Command + or Option + Command + in OS X. Another nice navigation feature is the tab stack. To go forward in the stack, press Ctrl + Tab, and press Ctrl + Shift + Tab to go backwards. On OS X also, it's Control and not Command this time.

There are more nice Go To features such as Go To line by pressing Ctrl + G, and Go To matching bracket with Ctrl + M.

Sublime's command palette

One of the most important features is the command palette where all the custom features or plugins can be accessed. Open the command palette by pressing Ctrl + Shift + P, or Command + Shift + P on OS X. We should see the following screenshot:

This window is using the same search algorithm that the Go To Anything window uses. We can see that I typed CA and I get the Close All command. Pressing Enter will close all open tabs. Don't worry, it will notify if a file we are trying to close has not been saved. We can see any keyboard shortcuts to the right of each command.

The Python console

Sublime comes with an embedded Python interpreter. It's a useful tool to inspect the editor's settings, quickly test API calls while developing plugins, or just do simple math. To open the Python console, press Ctrl+` or go to View | Show Console from the main menu. The following screenshot shows a Python console:

It's important to know that Sublime comes with its own Python interpreter on Windows and Linux, and it's separate from your system's Python installation. Modifying your system's version of python, such as replacing it with the MacPorts version, can cause problems with Sublime Text.

You have been reading a chapter from
Mastering Sublime Text
Published in: Dec 2013
Publisher: Packt
ISBN-13: 9781849698429
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image