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
"tab_size": 4
  • unindent with shift tab
"shift_tab_unindent": true
  • display white spaces
"draw_white_space": "all"
  • Display rulers
"rulers":[80,100],

Here is my config file:

{"auto_complete": false,
"auto_match_enabled": false,
"color_scheme": "Packages/User/Monokai (SL).tmTheme",
"detect_indenation": false,
"dictionary": "Packages/Language - English/en_US.dic",
"draw_white_space": "all",
"font_size": 10,
"ignored_packages":
["Vintage",
],
"index_exclude_patterns":
[
"*.log",
],
"rulers":
[
80,
100
],
"shift_tab_unindent": true,
"tab_size": 4,
"translate_tabs_to_spaces": 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 😉 ).

Advertisements

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.

latex : managing vertical space in itemize

A useful package to reduce space before and inside an itemize/enumerate command.

\usepackage{enumitem}

\setlist{nolistsep}

nolistsep remove all extra spaces in itemize and enumerate call.

If you just want to  remove vertical space (not the space before and after ), instead of nolistsep you prefer use :

\setlist[1]{itemsep=-5pt}

from http://stackoverflow.com/questions/1061112/eliminate-space-before-beginitemize

and http://tex.stackexchange.com/questions/21188/reduce-linespread-between-item-globally


latex 2 Word 2010

If for some (probably bad 🙂 ) reasons, you have to convert your whole latex document into a microsoft word one,  here are some useful tricks :