Sublime Text Extensions

If Sublime Text is become my favourite text editor, it’s principally due to the huge amount of available extensions.

I’d like to share here my default ones.

Package Control

Once sublime text installed, the first step consist into adding the package control, in order to install the following extension in a heartbeat:

Once package control install, you could install further extensions by hitting : CTRL+SHIFT+P and choose “install package”

 

My Favourite Extensions

Now, I’ll list some useful package for python development :

  • GitSavy : Manage git repository directly in Sublime Text. The interface is very clear and this truly improve the git experience. You can just take a look on the animated gif on the github page for convincing you.
  • GitGutter : Display modification between your current code and last commit
  • Ctags(*): Brings the classical vim Ctags to sublime text. You can thus directly go to function definition using the “CTRL+T CTRL+T” (twice) shortcut.
  • Origami : Split windows using keyboard shortcuts
  • SideBarEnhancements : To increase te capability of sidebar (rename files, quickview,…)
  • LaTexTools : Editing Latex into sublime text
  • Pylinter : A python linter directly integrated in Sublime Text ( Note: require a manual installation and configuration of pylint.) I stop using pylinter due to the huge amount of used CPU. I probably get back later.

Many other useful extensions can be found on https://packagecontrol.io/ ,  here and  here (French)

 

(*) Ctags also require to specify a language to operate correctly. For e.g. Python, this can be specified in the user settings of ctags with :

{
“commands”:”–languages=python”
}

Then you can just it “CTRL+T CTRL+R” to launch/reload the ctags indexation of your files.

Advertisements

sublime text shortcuts in IPython / Jupyter notebook

If you are a daily user of sublime text, you probably feel very frustrating to not have your classical shortcuts into the IPython/Jupyter notebook.

Hopefully the version 4 of Jupyter allows you to retrieve your favorite sublime text keybinding in your browser.

You just have to copy/paste the following line and add it into your ~/.jupyter/custom/custom.js file :

require(["codemirror/keymap/sublime", "notebook/js/cell"],
function(sublime_keymap, cell) {
cell.Cell.options_default.cm_config.keyMap = 'sublime';
}
);

Thats it , now you can launch your notebook and start editing without complains ūüôā

If it does not work, you may also try to replace the code above by this one :


require(["codemirror/keymap/sublime", "notebook/js/cell", "base/js/namespace"],
function(sublime_keymap, cell, IPython) {
// setTimeout(function(){ // uncomment line to fake race-condition
cell.Cell.options_default.cm_config.keyMap = 'sublime';
var cells = IPython.notebook.get_cells();
for(var c=0; c< cells.length ; c++){
cells[c].code_mirror.setOption('keyMap', 'sublime');
}

    // }, 1000)// uncomment  line to fake race condition 
} 

);


Sublime Text

Sublime Text is a wonderful code editor. In addition to several powerful features, the main interest of the tool is the possibility to add extensions.

Extensions

See the dedicated post on My favorites Sublime Text extensions

Configuration File

The Sublime text configuration is done through a Json file. Here is some configuration keys:

  • shift tab indent length
&amp;amp;amp;quot;tab_size&amp;amp;amp;quot;: 4
  • unindent with shift tab
&amp;amp;amp;quot;shift_tab_unindent&amp;amp;amp;quot;: true
  • display white spaces
&amp;amp;amp;quot;draw_white_space&amp;amp;amp;quot;: &amp;amp;amp;quot;all&amp;amp;amp;quot;
  • Display rulers
&amp;amp;amp;quot;rulers&amp;amp;amp;quot;:[80,100],

Here is my config file:

{&amp;amp;amp;quot;auto_complete&amp;amp;amp;quot;: false,
&amp;amp;amp;quot;auto_match_enabled&amp;amp;amp;quot;: false,
&amp;amp;amp;quot;color_scheme&amp;amp;amp;quot;: &amp;amp;amp;quot;Packages/User/Monokai (SL).tmTheme&amp;amp;amp;quot;,
&amp;amp;amp;quot;detect_indenation&amp;amp;amp;quot;: false,
&amp;amp;amp;quot;dictionary&amp;amp;amp;quot;: &amp;amp;amp;quot;Packages/Language - English/en_US.dic&amp;amp;amp;quot;,
&amp;amp;amp;quot;draw_white_space&amp;amp;amp;quot;: &amp;amp;amp;quot;all&amp;amp;amp;quot;,
&amp;amp;amp;quot;font_size&amp;amp;amp;quot;: 10,
&amp;amp;amp;quot;ignored_packages&amp;amp;amp;quot;:
[&amp;amp;amp;quot;Vintage&amp;amp;amp;quot;,
],
&amp;amp;amp;quot;index_exclude_patterns&amp;amp;amp;quot;:
[
&amp;amp;amp;quot;*.log&amp;amp;amp;quot;,
],
&amp;amp;amp;quot;rulers&amp;amp;amp;quot;:
[
80,
100
],
&amp;amp;amp;quot;shift_tab_unindent&amp;amp;amp;quot;: true,
&amp;amp;amp;quot;tab_size&amp;amp;amp;quot;: 4,
&amp;amp;amp;quot;translate_tabs_to_spaces&amp;amp;amp;quot;: true
}

Projects

When you’re working to a project, you can add all¬†related file into a sublime text project. To this end:

Go to Project=> Add Folder to Project

Select your project directory and now all your files are available in the side bar ( View -> side bar -> show sidebar or CTRL+K then CTRL+B).

Then your files can be reached by the Goto Anything feature (see next section)

Then you can save you project (Project -> save Project), and use the Project Quick switch feature (CTRL+ALT+P)

Shortcuts

Some very useful shortcuts for Ubuntu:

Code Navigation

  • CTRL+P :¬†Go to Anything (a.k.a. type to open a file from your project)
  • CTRL+R :¬†Go to Function, in a given file, find a class/method
  • CTRL+P+: : Go to Line
  • F5 : go to definition (function, class,….)
  • ALT+- /¬†ALT+SHIFT+- : jump¬†back and Forward¬†(a.k.a. go back and forward in cursor position ). This is a really powerful feature !
  • CTRL+SHIFT+T : re-open last closed tab

Selection

  • selection and CTRL+D : select one by one all occurrences of selection ( press CTRL+K to skip current selection)
  • selections and CTRL+L :¬†Multiple cursor at selections positions
  • selection and¬†ALT+F3 : select all occurrences of the selection

Snippets

Sublime text support snippets and activate them through a trigger key (e.g. hit TAB). Snippets are very easy to configure using the documentation.

You just have to create a file with the extension : .sublime-snippet and put it into the Sublime Text User  directory.

Example : ipdb

Here is a quick look of the features I use the most in Sublime Text.¬†I’ll try to update this article simultaneously to my future discoveries (a.k.a. your suggestions in comments ūüėČ ).


backward sync using okular + sublime text 2 + latextool

I recently discover Sublime text 2 (ST2), and it’s definitely ¬†my favorite IDE for ¬†python and latex (at least)!¬†Using Latextool plugin of ST2 allows to compile your latex code with pdflatex and obviously see the result into the default ubuntu pdf viewer tool : Evince.¬†The bad thing here, is that the backward sync (from the pdf, find the corresponding part of your code) doesn’t work for me.

So I’ve decided to move to Okular to get that synchronization working again. And it work under the condition to have the correct okular configuration which is :

Settings => Configure Okular => Editor

Chose Custom text editor and add the following line :

<path_to_your_sublime_text2_app>/sublime_text %f:%l

And here we go, you have the backward synchro.

However , it remains some other minor issues to solve :

  • ¬†launch okular by default after pressing CTRL+B in Sublime text
  • activate the forward synchro.