How I used Sublime Text 3¶
About…¶
About this page¶
This page is there to quickly describe how I use on a daily basis the awesome Sublime Text 3, a multi-platform text editor.
Note
What is a text editor?
« A text editor is a software for creating and editing text files. »
« Its use is common, even essential for some basic computing tasks such as system administration and software development.. »
Needless to say that I use a text editor constantly, mostly on Linux (Ubuntu 17.10), and on Windows (7/8/10).
The Wikipedia page on text editors contains a list of the most popular publishers multi-platform text. Sublime Text is obviously on the list, along with gedit, the two legendary Emacs and Vim, and for example Komodo Edit.
This article contains quick explanation of the installation and use of Sublime Text (2 or 3), and also a list of the best plugins that I use with ST3, links to my configuration files and general remarks.
(And weirdly, this page is one of the more popular of my website. Please contact me if you have any suggestion to improve it, or to say thanks if this page has been useful to you :) !)
Note
Licence?
This page, and all related files are freely distributed under the terms of the licence GPLv3 ! (Like anything else published or distributed on this website).
About Sublime Text 3¶
The official website is www.SublimeText.com/3. My article focuses on version 3 of Sublime Text (currently, version 3.083, released the 26th of March 2015).
Avertissement
Live dangerously :) ?
You can also try the version 3dev, it is updated more frequently (but you will need to be registered ie have a non-free license – I didn’t).
Voir aussi
- Visual Studio Code
is also a wonderful editor! It is developed by Microsoft, but it has the advantage to be fully open-source and free. After 4 years of intensive use, I am slowly giving up on Sublime Text to only use Visual Studio Code, and like Edith Piaf « non, je ne regrette rien »…
What is Sublime Text?¶
Sublime Text is a text editor and source code available on multiple platforms. It has an API using Python.
Sublime Text is a proprietary software, subject to the acceptance of a license, but is completely free. The (free) license is for an indefinite period, with only occasional reminders proposing to buy a non-mandatory commercial license (for $ 20).
Sublime Text incorporates most of the basic features of a text editor, including customizable syntax highlighting, auto-completion, a plugin system …
But that awesome text editor offers more advanced features, including:
Minimap: previewing entire file in a sidebar,
Selecting and editing in several sections of code in parallel (multi-cursor),
Bookmark even within files,
Automatic backup,
Search and replace with plain text or regular expressions,
Support for macros and plug-ins written in Python ,
Customizing keyboard shortcuts.
How to install ST3?¶
The official website www.SublimeText.com/3 gives links to the last version of ST3 on every supported platforms.
This page docs.sublimetext.info/en/sublime-text-3/getting_started/install.html explains in details how to install ST3 on different platforms process.
It’s easy, free and fast :) !
How to install plugins?¶
Note
Plugin ?
For computer softwares, plugins are additional components that completes a software host to provide it with new features.
Sublime Text can be equipped with a package manager that allows users to find, install, update and remove additional packages without even having to restart Sublime Text!
This project is simply called Sublime Text Package Manager, and is hosted on this site packagecontrol.io. This page packagecontrol.io/installation will tell you how to install the package manager, which is the only step a little dirty (but do not worry, no risk).
This magical plugin has already been downloaded more than 3.01 million times from the beginning of the project!
You can get a glimpse of the richness of this collection of plugin by going to this list (packagecontrol.io/browse/popular) of the most downloaded plugins.
A lot more details elsewhere!¶
This site is the unofficial documentation, but it is the main reference: docs.sublimetext.info. Congratulations to them, their website is very well designed and contains all the necessary information and much more!
This (old) wiki dedicated to Sublime Text can also help.
Voir aussi
These awesome lists also give very good advices, see djyde/awesome-sublime-packages, JaredCubilla/sublime, dreikanter/sublime-bookmarks.
How I use Sublime Text 3¶
My configuration¶
My configuration files, scripts and snippets of buildings for Sublime Text 3 are all in the folder publis/ST3.
To use one of these files (.sublime-settings
, .sublime-snippet
, .sublime-macro
or .sublime-build
), just copy it into your Packages/User folder.
More details for the .sublime-settings files, or the .sublime-build files.
- State:
Actively maintained (May 2016).
Config¶
My configuration files:
Preferences.sublime-settings is the main config file.
Distraction Free.sublime-settings is the specific configuration mode « distraction free ». I like this mode because it allows me to project code during a presentation or courses, and zoom in on up to an important element.
Package Control.sublime-settings just gives a complete list of installed packages (also packages.list).
Key shortcuts¶
Like (almost) everything else in Sublime Text, it’s easy to modify or add key shortcut for anything. It can be done globally, or project wise or language wise.
Default (Linux).sublime-keymap are my custom shortcuts (I like
ctrl+e
to go the end of a line, like in Emacs, orctrl+maj+e
for beginning of a line),Python.sublime-keymap adds some Python-specific key shortcuts (to be used with Anaconda IDE).
Snippets¶
List of my snippets:
newpython.sublime-snippet to easily create a new Python script,
newpython3.sublime-snippet to easily create a new Python 3K script,
newscript.sublime-snippet to easily create a new GNU Bash script.
autotex.sublime-snippet to create an empty \(\LaTeX{}\) document powered by autotex.
StrapDownJS.sublime-snippet facilitates the creation of an Markdown/HTML file powered by my (awesome) project StrapDownJS!
Snippets for LaTeX, to quickly start a new empty environment (
\begin{stuff}…\env{stuff}
) related to math, for the following (non-standard) environment: defn, example, examples, proof, remark, remarks, theorem.
Build systems¶
Sublime Text (as with other good text editors), it is possible to build, run or compile your files automatically and easily. ST3 comes with build scripts for a dozen language, and it is easy to create and install new ones.
List of my build systems:
A Bash script can easily be executed (without arguments) with the build script bash.sublime-build.
An Octave script can easily be executed (without arguments) with the build script octave.sublime-build.
A \(\LaTeX{}\) document powered by autotex (allow you to not have to write any \(\LaTeX{}\) headers) can easily be compiled to a PDF thanks to this build script autotex.sublime-build (requires autotex and my pdflatex).
StrapDownJS.sublime-build make it easy to compile a HTML file that uses my (great) StrapDownJS javascript tool, to a PDF file (thanks to the script strapdown2pdf)!
Macro¶
With Sublime Text (as with other good text editors), it is possible to record a macro, a small sequence of actions, commands, shortcuts or clicks, and associate it a keyboard shortcut for instance.
List of my macros (just two right now):
copy-to-the-end-of-the-line.sublime-macro to select and copy the text of the current line, from the current cursor to the end of the line. I associated it the
Ctrl+Alt+e
keyboard shortcut.and copy-to-the-beginning-of-the-line.sublime-macro does the same thing, but select and copy the text from the current cursor to the beginning of the line. I associated it the
Ctrl+Alt+Maj+e
keyboard shortcut (as the modifierMaj
is already used forCtrl+e
« go to end of the line » andCtrl+Maj+e
« go to the beginning of the line »).
The best plugins?¶
All of these plugins are free, almost all are free and open-source, and they are all installable from the package manager (Ctrl+Shift+P
: « Package Control: Install Package »)
For each packet quoted below, a link to the information page on packagecontrol.io/packages/ is given.
Note
My own plugin?
In September 2016, I wrote a small plugin, simply because I was bored of having to use two shortcuts to switch between French and English for the spell-checking. The goal was to be able to switch from one language to another with only one key shortcut…
It gave this plugin, SwitchDictionary (for ST3 only), which only works for French and English, but does its job perfectly (ctrl+shift+s
switches between French, English and no spell-checking, and ctrl+shift+a
guesses between French and English, automatically).
My plugin is now available through PackageControl, cf. SwitchDictionary.
Small customization plugins:
Better Build System improves the « build system » feature on some very specific points (specific but useful!).
BracketHighlighter improves how opening and closing parentheses, and opening and closing tags are colored (
(
,[
,{
,<
etc).BufferScroll is interesting because it allows to keep in mind absolutely all positional information (sliders panel, buffer etc. for each file and each window).
Clickable URLs is simple but great: to highlight the URLs (local or Internet) addresses, and open them with a keyboard shortcut.
Dictionaries a for multi-lingual spell-check (English, French, …).
The small GitGutter will help to visualize the difference of each line of each file regarding the last committed version for the git repository in which it is located (visually great to see the changes since the last commit).
Gremlins help to visualize dangerous non-visible UTF-8 caracters, like odd and invisible whitespace characters.
Language - French - Français also adds various dictionaries for French.
Status Bar Weather adds unnecessary weather in the status bar at the bottom. Useless but fun. Yeah, your text editor can tell you the weather!
Boxy Theme (with « Boxy Tomorrow ») is my favorite theme, it brings a very refined but perfectly all smooth interface, suitable for optimum productivity and is cool with your eyes. It also have awesome icons for your side-bar!
Plugins that add great features:
Calculate to easily create ordered lists (among many other things): write
i+1
on each line, then one hit ofCtrl+Maj+c
and pouf, the multi-selection is now1
,2
, …,n
.DictionaryAutoComplete enables auto-completion to integrate the words of dictionaries used for spell checking. Quite cool but can quickly be boring. Can be useful if you write prose and not code (project report, poetry etc).
HighlightWords to always highlight some specific words (for instance,
TODO
orFIXME
).IncDecValue allows to easily increment or decrement numbers, dates or colors.
InsertDate allows to easily add today’s date with a key shortcut (
F5
by default), like this: Wednesday 25 November 2015, 22:21:57.LineEndings to highlight and easily erase the painful (and unnecessary) spaces at the end of lines.
MakeCommands will launch from the control panel of any rule of construction from a Makefile. It’s simple, but purely awesome! I use a lot of Makefile for my various projects. Such an efficient idea in fact!
SideBarEnhancements makes the sidebar much more useful.
The wonderful SublimeGit (installable from packagecontrol.io/packages/SublimeGit). Allows a full integration of git via the control panel. Free but annoys you regularly to ask you buy a (useless) 10$ commercial license… But it is really awesome, so you will support this. GitSavvy seems to be a good free and open-source alternative.
TableEditor is great to easily edit tables in plain text documents (for Markdown, reStructedText, pandoc etc). Very well documented and quite complete.
Terminal to open a terminal (ie. a console) already in the correct folder. I never use it, but it works well. More details on wbond.net/sublime_packages/terminal.
Wakatime to use Wakatime.com (read this other article for more explanations).
WordCount adds a counter for words (and pages) in the information bar. Small and simple but useful!
A better support for some languages:
AutoDocstring simplifies and improve significantly the writing of Python docstrings (2 or 3), and even supports the two popular styles Google docstring and Numpy docstring.
ColorHighlighter highlights the colors in a CSS, HTML or LaTeX file (or any file), for instance
red
will be colored red. Simple but great, very useful when editing CSS or colorful LaTeX files.ColorPicker allows you to select a color, and insert it as is. Very handy when writing CSS or HTML.
Dotfiles Syntax Highlighting brings a clever coloring for about a hundred of Linux/Unix configuration file formats, the so called « dotfiles ».
Gnuplot provides good support for programming with GNUPlot v4+.
JSONLint automatically checks the correctness of any edited JSON file (and ST conf” files are JSON).
LaTeX-plus could improve the use of LaTeX in ST (see the doc).
Markdown Extended is supposed to improve the syntax coloring for Markdown, lightweight markup language, designed for easy preparation of document. I use Markdown especially via my project StrapDownJS ! (See an example ?)
nginx improve the syntax coloring for config files for the awesome NGinx web server.
OCaml improve a little bit the syntax coloring for the two languages caml-light and OCaml. To be used with OCaml Autocompletion.
GNU Octave Completions and Matlab Completions adds functions and commands from GNU Octave or MATLAB to the completion window.
RestructuredText Improved improve significantly the syntax coloring for reStructedText, the markup language used by Sphinx and the official Python documentation (and so for this page and my site). To be used with these snippets for rST.
SublimeRegexExplainTip helps to better understand how regular expression work (« regexp »), like the web-site regex101.com.
requirements.txt adds a very good support for Python requirements.txt files.
TWiki for its color theme, brilliantly balanced and well colored. I use their syntax coloring theme TWiki « Monokai for Markup » for every language! After testing a lot of them, it really is my favorite color theme!
Heavier plugins, or plugins designed for a specific language:
MagicPython improves the syntax coloring for Python (it recognizes the new syntax features that came in the last versions 3.5 and 3.6).
MatlabFilenameAutoComplete adds the filename of the Matlab/Octave functions (ie the local files file.m) to the automatic tab completion. It is a way to compensate with the boring fact that Matlab/Octave asks to write any function as a seperate file…
The brilliant SublimeLinter checks the code you write for syntax error as you write it (Spyder does the same for Python, for example). Quite extraordinary! Anaconda IDE is far more powerful but specific to Python. There is plenty of awesome linters: annotations, chktex, flake8, json, mdl, pylint, shellcheck.
LaTeXing (installable from packagecontrol.io/packages/LaTeXing), improve support for \(\LaTeX{}\).
SendText+ is convenient to quickly « send » some code to an open terminal in another window (to work with Python, Octave, R, bash or any other toplevel).
SublimeCodeIntel is supposed to enable intelligent access to a program recognizing the definitions of variables, functions, classes, etc., it is expected to « jump » directly to the definition of any element of the program (I do not like it).
Emmet (installable from packagecontrol.io/packages/Emmet), improves writing HTML, CSS and Javascript documents quite magically. It surely takes time to master its features, but I guess it’s worth it!
Note
Purely subjective
This list simply reflects my daily use of ST3. These choices are purely subjective. For instance, this article also presents a list of good plugins to use.
Some plugin-specific configuration files¶
Some plugins can be configured specifically. Here are their different settings:
Some language-specific configuration files¶
In ST3, you can modify any single parameter for a specific language (for instance, a smaller font for Python files, a bigger margin for Markdown files etc). For a few languages, I find these changes quite convenient:
Objective-C.sublime-settings (my change allows to open a .m file as a Matlab/Octave file and not an Objective-C one),
Additional advice¶
As for every powerful and awesome software, Sublime Text 3 will require a certain training time.
Voir aussi
- Visual Studio Code
is also a wonderful editor! It is developed by Microsoft, but it has the advantage to be fully open-source and free. After 4 years of intensive use, I completely gave up on Sublime Text to only use Visual Studio Code, and like Edith Piaf « non, je ne regrette rien » (no, I don’t regret anything, a famous French song)…
Voir aussi
- Atom.io
Seems to be promising!
Additional credit¶
Thanks to Jill-Jênn Vie for advising me to use Sublime Text 3 (in Octobre 2013).