• Stars
    star
    248
  • Rank 158,071 (Top 4 %)
  • Language
    Python
  • License
    BSD 3-Clause "New...
  • Created almost 12 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Restructured Text snippets and code completion hotkeys for Sublime Text 2 and 3

SublimeText ♥ reStructuredText

sublime-rst-completion is a group of snippets and commands to facilitate writing restructuredText with SublimeText.

Demo

(image links to a Youtube video)

http://img.youtube.com/vi/otM_tjIi_vY/0.jpg

Install

The easiest way to install is via Sublime Package Control . Just look for "Restructured Text (RST) Snippets"

Otherwise you can:

  • Clone the repository into your packages folder:

    git clone [email protected]:mgaitan/sublime-rst-completion.git
    
  • Or download the .zip file and unzip it into your ST2/ST3 packages directory.

Optionally, to use the Render preview feature, you need to install at least one of Pandoc, docutils or rst2pdf and they should be accessible in your PATH. (Copy the command_path variable from the package's settings file to your user settings file and add paths to your local installations to it.) In debian/ubuntu you can install them via apt-get:

$ sudo apt-get install pandoc docutils rst2pdf

Usage

Simple snippets work as tab-triggered shortcuts: type the shortcut and press <TAB> to replace it with the snippet. If the snippet has placeholders, you can jump between them using tab.

shortcut result key binding
h1 Header level 1 see Headers
h2 Header level 2  
h3 Header level 3  
e emphasis ctrl+alt+i (super+shift+i on Mac)
se strong emphasis (bold) ctrl+alt+b (super+shift+b on Mac)
lit or literal literal text (inline code) ctrl+alt+k (super+shift+k on Mac)
list unordered list see Smart Lists
listn ordered list  
listan auto ordered list  
def term definition  
code code-block directive (sphinx)  
source preformatted (:: block)  
img image  
fig figure  
table simple table ctrl+t see Magic Tables
link refered hyperlink  
linki embeded hyperlink  
fn or cite autonumbered footnote or cite alt+shift+f see Magic Footnotes
quote Quotation (epigraph directive)  

Also standard admonitions are expanded:

shortcut
attention
caution
danger
error
hint
important
note
tip
warning

Render preview

You can preview your document in different formats converted with different tools pressing ctrl+shift+r.

The Quick Window will offer the format and tool and the result will be automatically open after the conversion.

By the moment, it can use Pandoc, rst2pdf, or rst2*.py tools (included with docutils) to produce html, pdf, odt or docx output formats.

Each time you select a format + tool option, it turns the default the following times.

Note

The original code is from the SublimePandoc project.

Magic Tables

There is a particular magic expansion for tables. Here is how it works:

Grid table

  1. Create some kind of table outline, separating column with two or more spaces:

    This is paragraph text *before* the table.
    
    Column 1  Column 2
    Foo  Put two (or more) spaces as a field separator.
    Bar  Even very very long lines like these are fine, as long as you do not put in line endings here.
    
    This is paragraph text *after* the table.
    
  2. Put your cursor somewhere in the content to convert as table.

  3. Press ctrl+t, enter (Linux or Windows) or super+shift+t, enter (Mac). The output will look something like this:

    This is paragraph text *before* the table.
    
    +----------+---------------------------------------------------------+
    | Column 1 | Column 2                                                |
    +==========+=========================================================+
    | Foo      | Put two (or more) spaces as a field separator.          |
    +----------+---------------------------------------------------------+
    | Bar      | Even very very long lines like these are fine, as long  |
    |          | as you do not put in line endings here.                 |
    +----------+---------------------------------------------------------+
    
    This is paragraph text *after* the table.
    

Now suppose you add some text in a cell:

+----------+---------------------------------------------------------+
| Column 1 | Column 2                                                |
+==========+=========================================================+
| Foo is longer now     | Put two (or more) spaces as a field separator.          |
+----------+---------------------------------------------------------+
| Bar      | Even very very long lines like these are fine, as long  |
|          | as you do not put in line endings here.                 |
+----------+---------------------------------------------------------+

Press the same trigger: magically, the structure will be fixed:

+-------------------+--------------------------------------------------------+
| Column 1          | Column 2                                               |
+===================+========================================================+
| Foo is longer now | Put two (or more) spaces as a field separator.         |
+-------------------+--------------------------------------------------------+
| Bar               | Even very very long lines like these are fine, as long |
|                   | as you do not put in line endings here.                |
+-------------------+--------------------------------------------------------+

In addition, if you would like to keep the column width fixed, you could reflow the table pressing ctrl+t, r (super+shift+t, r in Mac). The result would be this:

+----------+---------------------------------------------------------+
| Column 1 | Column 2                                                |
+==========+=========================================================+
| Foo is   | Put two (or more) spaces as a field separator.          |
| longer   |                                                         |
| now      |                                                         |
+----------+---------------------------------------------------------+
| Bar      | Even very very long lines like these are fine, as long  |
|          | as you do not put in line endings here.                 |
+----------+---------------------------------------------------------+

With the base trigger combination and the cursors you can merge simple cells. For example, suppose you have this table:

+----+----+
| h1 | h2 |
+====+====+
| 11 | 12 |
+----+----+
| 21 | 22 |
+----+----+

Move the cursor to the cell 12 and press ctrl+t, down. You'll get this:

+----+----+
| h1 | h2 |
+====+====+
| 11 | 12 |
+----+    |
| 21 | 22 |
+----+----+

Note

The original code of this feature was taken from Vincent Driessen's vim-rst-tables :

Note

The original code of wcwidth was taken to solve alignment issue with CJK characters.

Simple table

Instead of tables above, a simpler style table is also supported. Here is how it works:

  1. Create some kind of table outline, separating column with two or more spaces:

    This is paragraph text *before* the table.
    
    Column 1  Column 2
    Foo  Put two (or more) spaces as a field separator.
    Bar  Even very very long lines like these are fine, as long as you do not put in line endings here.
    
    This is paragraph text *after* the table.
    
  2. Put your cursor somewhere in the content to convert as table.

  3. Press ctrl+t, s (Linux or Windows) or super+shift+t, s (Mac). The output will look something like this:

    This is paragraph text *before* the table.
    
    ==========  ================================================================================================
    Column 1    Column 2
    ==========  ================================================================================================
    Foo         Put two (or more) spaces as a field separator.
    Bar         Even very very long lines like these are fine, as long as you do not put in line endings here.
    ==========  ================================================================================================
    
    This is paragraph text *after* the table.
    

Now suppose you add some text in a cell:

==========  ================================================================================================
Column 1    Column 2
==========  ================================================================================================
Foo is longer now         Put two (or more) spaces as a field separator.
Bar         Even very very long lines like these are fine, as long as you do not put in line endings here.
==========  ================================================================================================

Press the same trigger: magically, the structure will be fixed:

===================  ================================================================================================
Column 1             Column 2
===================  ================================================================================================
Foo is longer now    Put two (or more) spaces as a field separator.
Bar                  Even very very long lines like these are fine, as long as you do not put in line endings here.
===================  ================================================================================================

Note

The original code of this feature was taken from Vincent Driessen's vim-rst-tables :

Smart lists

Ordered or unordered lists patterns are automatically detected. When you type something like this:

1. Some item
2. Another|

When press enter the newline will prepended with a logical next item:

...
2. Another
3. |

If you press enter when the item is empty, the markup is erased keeping the same indent as the previous line, in order to allow multilines items. Also note that orderer list works with an alphabetic pattern or roman numbers pattern suffixed with a period (a. b. c. ..., A. B. C. ..., i. ii. iii. iv. ..., X. XI. XII. ..., #.); surrounded by parentheses ((a) (b) (c) ..., (A) (B) (C) ..., (i) (ii) (iii) (iv) ..., (X) (XI) (XII) ..., (#)); or suffixed with a right-parenthesis. (a) b) c) ..., A) B) C) ..., i) ii) iii) iv) ..., X) XI) XII) ..., #));

Tip

The very same feature works for line blocks starting a line with |.

Note

This feature was proudly stolen from Muchenxuan Tongh's SmartMarkdown

Headers

Autocompletion

You can autocomplete standard headers (over/)underlines with TAB.

For example try this:

**********<TAB>
A longer main title
*******

Or this:

A subtitle
---<TAB>

You'll get:

*******************
A longer main title
*******************

A subtitle
----------

respectively.

Folding/unfolding

If you put the cursor in a completed header and press shift + TAB (alt + TAB in Mac), the section under it will be folded/unfolded.

For example:

Folding/unfolding
+++++++++++++++++<TAB>

If you put the cursor in a completed header and press ``shift + TAB``,
(``alt + TAB`` in Mac) the section under it will be folded/unfolded.

Navigation
++++++++++

...

Result in:

https://raw.github.com/dbousamra/sublime-rst-completion/11_foldable_headers/img/folding.png

Nested sections under a header are included.

Navigation

Also, it's possible to jump between headers. alt+down and alt+up move the cursor position to the closer next or previous header respectively.

alt+shift+down and alt+shift+up to the same, but only between headers with the same or higher level (i.e. ignore childrens)

The header level is detected automatically.

Adjust header level

With the cursor in a header, press ctrl + + (plus key) and ctrl + - (minus key) (alt + + and alt + -, in Mac) will increase and decrease the header level respectively. The adornment decoration (underline / overline) are autodetected from the document and uses Sphinx's conventions as default.

For example, you have the cursor in:

Magic Footnotes|
---------------

Which is a header level 2 and want to convert to a level 3, press ctrl + - to get:

Magic Footnotes
+++++++++++++++
|

Magic Footnotes

This is the smarter way to add footnotes, grouping them (and keepping count) in a common region at the bottom of the document.

When you want to add a new note, press alt+shift+f. This will happen:

  • A new n+1 (where n is the current footnotes count) note reference will be added in the current cursor position
  • The corresponding reference definition will be added at the bottom of the footnotes region
  • The cursor will be moved to write the note

After write the note you can go back to the reference with shift+up. Also, if the cursor is just after a reference (i.e: the caret is next to the underscore like this [XX]_| ) you can jump to its definition with shift+down [1].

This feature is based on the code by J. Nicholas Geist for MarkdownEditing

Authors

Tip

Pull requests and bug reports are welcome!

License

It's under a BSD license .

[1]in fact, you can also jump forward and back between notes with the general alt+shift+f

More Repositories

1

waliki

A wiki engine powered by Django and Git
Python
309
star
2

sphinxcontrib-mermaid

Mermaid diagrams in yours sphinx powered docs
Python
281
star
3

curso-python-cientifico

Curso de Python orientado a estudiantes de ciencias e ingeniería, profesores, investigadores e ingenieros
Jupyter Notebook
152
star
4

fortran_magic

An extension for IPython/Jupyter that helps to use Fortran in your interactive session.
Python
115
star
5

preciosa

Inteligencia colectiva contra la inflación
Python
67
star
6

departamentos_argentina

Geojson/Topojson de Argentina a nivel departamentos
40
star
7

django-orm-magic

An extension for IPython that help to define and use django's models on the fly
Jupyter Notebook
23
star
8

pytest-line-profiler

Profile code executed by pytest, line by line.
Python
22
star
9

radiocut_downloader

Download contents from radiocut.fm
Python
20
star
10

pymips

A pipelined MIPS processor implemented in Python
Python
19
star
11

miau

Remix speeches for fun and profit
Python
17
star
12

waliki_flask

A simple yet powerful wiki engine -- Deprecated. New version:
JavaScript
17
star
13

moin2git

Migrate a MoinMoin wiki as a Git repository
Python
15
star
14

tisu

your project's issue tracker, in a text file
Python
8
star
15

preciosa_mobile

Aplicación cliente para smartphones del proyecto Preciosa
JavaScript
7
star
16

sqlalchemy-pretty-sql

Given a sqlalchemy query, display its well formatted and highlighted sql code.
Jupyter Notebook
7
star
17

elecciones_argentina_2013

Dump de datos en formato CSV del programa http://www.resultados.gob.ar/inimesas.htm
6
star
18

discursos_cfk

Discursos de Cristina Fernández de Kirchner
Python
4
star
19

mgaitan.github.io

>>> self.geek.post() (Mi weblog técnico)
HTML
4
star
20

one

one, the missing Python function
Python
4
star
21

forn

contratapas de Juan Forn en Página/12
HTML
4
star
22

f2f_online

Online Fortran 77 to Fortran 90/95 conversor
JavaScript
4
star
23

pytest-leak-finder

Find the test that's leaking before the one that fails
Python
3
star
24

trestapas

A platform to analyze historical newspaper discourses
Python
3
star
25

myhdl-talk

Slides and notes for a MyHDL talk on Cordoba PyDay 2011, Argentina
JavaScript
3
star
26

pytest-portion

Select a portion of the collected tests
Python
3
star
27

h2dp

Hamster to dotProject logs sync tool
Python
3
star
28

pasaron-cosas

https://mgaitan.github.io/pasaron-cosas/slides.html
HTML
3
star
29

git-hooks

scripts to be used as git hooks
Python
2
star
30

clarin_lta

Ignorar la ventana de login obligatoria de clarin.com o lavoz.com.ar
HTML
2
star
31

precios_maximos

Listados de Precios Maximos de Referencia por provincia
Python
2
star
32

gh-weekly

GitHub CLI extension that generates a weekly report in markdown listing the PRs worked on
Shell
2
star
33

hamster2jira

Post your Hamster logs into Jira
Python
2
star
34

intro-git

Introducción a Git - Charla 8va Jornadas de Software Libre de la UNNOBA
JavaScript
2
star
35

my-nikola-theme

The theme for mgaitan.github.io
JavaScript
2
star
36

gpec2010

Python
2
star
37

django-milligram

Django base template powered by Milligram
HTML
1
star
38

haztelibro

give a file with a list of urls, get a readable epub
Python
1
star
39

mezzanine-pagedown

Fork from https://bitbucket.org/akhayyat/mezzanine-pagedown
JavaScript
1
star
40

hay-camisetas-bot

¿Hay camisetas ⭐⭐⭐?
Python
1
star
41

awesome-scipy

A curated list of python resources for science
1
star
42

en-pija

Generador online de "En pija approved"
1
star
43

elecciones_argentina_2015

dump en CSV y sqlite3 de los resultados del escrutinio provisorio de las presidenciales 2015
1
star
44

video2ebook

A software based book scanner from videos
1
star
45

battleship

Generador de tableros de batalla naval
JavaScript
1
star
46

nikolahub

Your Nikola blog rendered in the cloud
Python
1
star
47

datasets_preciosclaros

Datasets resultantes del scraper de preciosclaros.gob.ar
Jupyter Notebook
1
star
48

10consejos

10 consejos para un mejor software (de) científico(s)
JavaScript
1
star
49

presentacion_proyecto_final_gpec

Encontré las diapositivas de presentación de mi proyecto final
HTML
1
star
50

esquedulin

Automatically exported from code.google.com/p/esquedulin
Python
1
star
51

escuelas_argentinas

datasets (y scraper) de establecimientos educativos
Python
1
star
52

wikibora

Una plataforma para el anotado colaborativo de Boletines Oficiales
1
star
53

charla_py3

Python 3 para escépticos
Jupyter Notebook
1
star