Writing Sublime Plugins
Writing Sublime Plugins


This book is no longer available for sale.

Writing Sublime Plugins

This book is 90% complete

Last updated on 2014-03-12

About the Book

"Wait, Sublime doesn't already do this?!?"

When you discovered Sublime Text, it was like coming home. Multi-select is bliss. Easy to customize. Plugins galore.

You’ve gone all in—even ponied up for a paid license.

And now, months later, you still feel that way. But…

There’s this ONE THING you can’t live without … And Sublime doesn't have it.

Why, why, why? Isn’t this just a basic feature? Every editor should do this...

Sublime doesn’t, though. You’ve even scoured the interwebs, looking for a plugin that does what you want, but come up dry.

It wouldn’t be so bad, really, if it wasn’t something you needed every day. Often multiple times.

So you grit your teeth, switch to your old editor. Actually you don’t even close it anymore.

Such a hacky workaround. It knocks you out of the zone, breaks your concentration, ruins your mood.

But rather than resigning yourself to a two-editor life ...

What if you could take charge and add that missing feature yourself?

If you knew how to tap into Sublime’s rich API and extension mechanisms, you’d look at problems differently.

  • Instead of wasting time on the same task, day after day, you could write a plugin to automate it away.
  • Instead of trying to cobble features together and almost getting what you want, you could create a plugin that gets the job done right.
  • Instead of getting annoyed by repetitive manual tasks, you’d see them as opportunities to create plugins—which you could share with the community so hundreds of thousands around the world could reap the same benefits.

You'd know how to unlock the full power of Sublime Text, and you'd enjoy your experience with Sublime even more deeply.

Writing Sublime Plugins will show you how easy it is to create your own Sublime plugins—even if you’ve never written Python before.

The book will walk you step by step through creating a real Sublime plugin, explaining key concepts and pointing out common pitfalls along the way.

Some highlights include:

  • More than 140 pages packed with code and real examples.
  • 30 code snapshots that help you can see how the examples work and test them in your own copy of Sublime.
  • What Sublime plugins can do—and what they can’t.
  • How many of the features you think of as baked into Sublime really aren’t, and how this can help you.
  • Why anyone with basic programming experience can write a plugin—no Python experience required.
  • 9 debugging tricks that will save you hours of frustration.
  • The professional touches that make your plugin stand out from the crowd.
  • A way to hack the Sublime API to see exactly what is causing an error.
  • The Rosetta Stone for the Sublime API.
  • Where to go for more information.
  • The different types of Sublime plugins, and what each is good for.

Who is this book for?

If you've been kicking around an idea for a Sublime Text plugin, but you're not sure how to get started, this book is for you.

On the other hand, if you're already an experienced plugin developer looking for a deep dive on the Sublime APIs, you might not find much new information here.

The book is aimed at programmers with experience in a language like Ruby, JavaScript, PHP or C#. If you're a programmer with some solid experience with programming applications, you shouldn't have any trouble following along. But if your programming experience is limited to basic JavaScript or jQuery, you might have a tough time keeping up.

Sublime plugins are written in Python, and familiarity this language helps but is no means required.

No risk — UNLIMITED money-back guarantee

Nearly 1,200 developers have purchased my first book, Sublime Productivity, and I can count the number of refunds on my fingers.

But I want to make absolutely sure you're satisfied.

That's why I'm personally offering an unlimited money-back guarantee.

If you're not satisfied with Writing Sublime Plugins at any point, just email me (my address is in the book) and tell me why and I'll personally send you a refund through PayPal.

About the Author

Josh Earl
Josh Earl

Josh Earl is a software developer, writer and total text editor geek. He loves learning the ins and outs of whatever tool or platform he finds himself working on and tweaking his daily workflow to eliminate mundane and repetitive tasks. He blogs about Sublime Text at sublimetexttips.com.

Table of Contents

    • Contact Me
    • Learn more about your favorite editor
    • Did you get this book “for free”?
    • Introduction
  • I What is a Sublime plugin?
    • 1. What is the difference between a package and a plugin?
    • 2. What can a Sublime plugin do?
    • 3. What restrictions does Sublime place on plugins?
    • 4. Hello World
  • II Event listeners
    • 5. Introducing the KeyBindingInspector plugin
    • 6. Setup
    • 7. Implementation overview
    • 8. What is an event listener?
    • 9. Hello World, event listener edition
    • 10. Dead end
  • III Commands
    • 11. Implementation overview
    • 12. What is a command?
    • 13. Converting the plugin to a command
    • 14. Listing installed packages
    • 15. Listing package files
    • 16. Reloading modules
    • 17. Filtering out ignored packages
    • 18. Listing key map files
    • 19. Filtering the file list to include only key maps
    • 20. Saving key map file names to a list
    • 21. Listing keyboard shortcuts
    • 22. Parsing JSON
    • 23. Adding command palette support
    • 24. Displaying keyboard shortcuts in a quick panel
    • 25. Processing files on a background thread
    • 26. Displaying a progress bar
    • 27. “Executing” commands on selection
    • 28. Cleaning up the entry formatting
    • 29. Adding user settings
    • 30. Integrating plugin settings into Sublime’s menus
    • 31. Adding a key binding
    • 32. Adding Sublime Text 3 support
    • 33. What major changes does Sublime Text 3 introduce?
    • 34. Refactoring for Python 3.3 syntax
    • 35. Submitting to Package Control
  • IV Debugging
    • 36. Debugging in a mixed environment
    • 37. Debugging strategies
  • V Resources
    • 38. Learning more

Other books by this author

Authors have earned$9,386,802writing, publishing and selling on Leanpub,
earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.

Learn more about writing on Leanpub

The Leanpub 45-day 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses! Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks. Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. It really is that easy.

Learn more about writing on Leanpub