Python sublime text package control

How to Use Sublime Text for Python

Sublime Text’s rich package ecosystem makes it possible to fine-tune the text editor specifically to what you are using it for. Some of the packages are universally helpful, others, such as syntax checking, are specific to the programming language you are working with.

Changing settings is easy and might also help to clarify how to do further customizations — if that is where your ❤ is at.

Keep reading below for step-by-step guidance on how to use Sublime Text for Python.

Sublime Settings

Before moving onto installing plugins, there are a couple of useful settings that can help to tailor your Sublime Text for Python development. Go to Sublime Text → Preferences → Settings and in the Preferences.sublime.settings-User file enter the following rules:

I personally prefer to keep “spell_check” on false because I don’t like to see red lines everywhere when writing non-dictionary-compliant words. Maybe I’m just damaged by the school system. If you have a different opinion on this, simply set “spell_check” to true.

The magic numbers for the “rulers” setting originate from pythons PEP8. Docstrings and comments should be limited to 72 characters and all other lines should not be longer than 79 characters. The ruler lines can help to remind you when you are approaching these limits.

Читайте также:  Java вычисления в потоке

In good Python fashion we set the “tab_size” to 4 and “translat_tabs_to_spaces” to avoid relationship troubles.

Anaconda

Note: this is not the popular python distribution often used for data science that goes by the same name.

The Sublime Text Anaconda plugin helps to make ST more IDE-like while keeping it still operating much quicker than most IDEs. It introduces easy access to useful features such as:

  • Code autocompletion
  • Code linting: syntax errors
  • Code linting: highlight and automatically fix PEP8 violations
  • Python documentation on class, method or function under the cursor
  • Goto Python definition anywhere in the project
  • Find object usage across the project
  • and lots more…

Auto Docstring

Auto Docstring does just what its name suggests — it allows you to swiftly create a Python docstring template for your selected function, method or class. You can even add docstrings for every function in a file and change between Google and Numpy style even after the docstrings were created. A very basic auto-generated example would look like this:

def my_function(): """Summary Returns: TYPE: Description """ return None

SublimeLinter

For Python syntax and PEP8 you could stick with using the linting provided through the Anaconda plugin. However, using SublimeLinter has the advantage that it is extensible also with other linters that are useful for web development. That’s why I would suggest to disable Anaconda’s linter, like so:

Use the file menu: Sublime → Preferences → Package Settings → Anaconda → Settings — User to go to the user-defined Anaconda settings file. Then set:

Now, install SublimeLinter using the Package Manager.

Note: Most of the linters require additional packages to operate correctly, so make sure to read the instructions carefully

SublimeLinter-pyflakes

pyflakes performs syntax checking on python files. This package needs to be installed using pip before adding it to ST with the Package Manager

SublimeLinter-pycodestyle

pycodestyle is the new name of the pep8 package. Install it using pip, then add it to Sublime using the Package Manager for PEP8-compliant code style linting.

Other useful linters for web development:

Djaneiro

This useful plugin adds a couple of handy Django snippets with tab autocompletion into ST to make working on web projects quicker.

Very cool. Check out all it has to offer here!

Git

Allows to do the most common set of git commands from within Sublime Text.
git add, commit, push etc. right from your favorite text editor.

GitGutter

GitGutter helps to keep track of which files have been edited since the last commit. It adds small symbols next to the line numbers that indicate their status in relation to the git repository.

requirementstxt

Introduces syntax highlighting for requirements.txt files. Be good to your 👀!

Markdown Preview

Allows to preview Markdown documents in your browser — build them using different available flavors!

Other useful Web Dev Packages

CSS3

The CSS3 plugin allows for futuristic CSS syntax highlighting. You’ll need to tweak the rest of the settings a bit, but it’s easy to follow along the steps on the site linked above.

ColorHighlighter

This one is fun. Adds more 🌈 to your code. Hex color values will be displayed with the corresponding color as background. Makes it easier to remember what color you were adding where.

Emmet

If you’re excited about automating the repetitive parts of your web development work, then Emmet can be a big help. Install the package, then learn how to benefit: https://docs.emmet.io/cheat-sheet/

Want to learn more?

There you have it, you now have a comprehensive guide for getting started on how to use Sublime Text for Python. With adding these packages and tweaking the settings as mentioned above, Sublime Text becomes a lightweight but powerful editor for web development.

If you are just getting started and are looking for a fun and affordable bootcamp that helps you to learn programming, check out CodingNomads’ upcoming Python courses. 🌇 💻 🎒🏝

More info on how to use Sublime Text for Python:

Plugin Setup:

Learn to increase your performance when working with ST3:

If you’re interested to learn about other Python IDEs:

Источник

Python and Cython language bundles

Bleeding-egde Python and Cython syntax highlighters and other goodies for Sublime Text 2/3 and TextMate editors.

(Or for any other editor, that is using the .tmLanguage syntax definition)

Preview

State of the Art

Below are some of the most important improvements compared to the existing syntax highlighters:

  • Added better number highlighting:
    • All types of floating point notations are working now;
    • All types of complex number notations are working now;
    • New types of binary and octal-number notations are supported;
    • Long integer is removed.
    • Better regex support (multiline, grouping, comments and more are improved).
    • Format specifier mini-language
    • Template strings
    • Byte notation added;
    • Proper string prefixes added.

    Future plans

    Installation

    Via Package Control

    The fastest and easiest way to install these packages for Sublime Text is the following:

    1. Install Package Control
    2. Open Tools → Command Palette
    3. Select Package Control: Install Package
    4. Search for Python 3 and Cython+ packages and install them
    5. Happy coding 😉

    Set as default

    After you installed the language definition file successfully, all you have to do is assign the .py files to always open with this syntax highlighter. Go to

    View → Syntax → Open all with current extension as. → Python 3

    To remove this setting, you can always overwrite this preference.

    Manual installation

    Download the tmLanguage files from the python and Cython branches of this repository. Navigate to your Packages folder and create a Python3 and/or a Cython folder(s) and copy the tmLanguage and sublime-build files into.

    If you want to use my Work-In-Progress theme file: navigate to Packages/User folder and copy Gloom.tmTheme into it. Then go to user-settings, and change your old color theme to the new one.

    Contribute

    Any help is appreciated and more than welcome – my goal is to make this the ‘de facto’ language bundle for python 3. If you want to submit a change, please use the following conventions when editing the original python files:

    • variables uses underscore_separated_names ;
    • all files uses 4 spaces for indentation;
    • = and : operators are aligned if length of variable names are similar;
    • ( , [ and < start a new line, if possible and reasonable;
    • each line must fit in the width 80 columns (code, text, etc.);
    • comment separators can be easily generated with the src.utils.separator() function

    Appreciation

    Thank you very much @joncle (Jon Clements) for all the support in general, @kms70847 (Kevin), @Ffisegydd (Keiron Pizzey), @schesis (Zero Piraeus) and @poke (Patrick Westerhoff) for the feedbacks, and of course thanks for all the wonderful members of the sopython chat room for supporting me in any ways! May the Cabbage be with us 😉

    I also want to thank for all the loyal users of this package, and especially @rahul-ramadas (Rahul Ramadas) and @bordaigorl (Emanuele D’Osualdo) who were very active on giving me feedbacks, reports, etc.

    License

    Copyright © 2013 — 2017 Peter Varo

    This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

    Источник

    How to Install Python Package in Sublime Editor

    Learn to install python package in sublime editor for features like autocomplete and run build within sublime editor itself.

    Table of Contents Install Sublime Package Control Install Package Python 3 Verify Python Autocomplete and Build

    Install Sublime Package Control

    First download the package control for sublime editor.

    1. Go to URL: https://packagecontrol.io/installation#st3Sublime package control
    2. Now note down the location of folder where packages are installed in sublime editor. You can find the location by clicking on Preferences > Browse Packages. Browse Packages
    3. Save the downloaded file from package control website on clicking “Package Control.sublime-package” link, and place it inside folder located at second step.
    4. Now restart the sublime editor by closing it and then open it again.
    5. To verify the package control is installed correctly, click on Preferences > Package Control menu item. It should open up the package control window. Package Control Menu
    1. Now to install any package support, including Python package, go to Preferences > Package Control and choose Install Package. Install Package Window
    2. In opened window, type ‘python’ to filter the list of packages related to python only. Select Python Package to Install

    Wait for few seconds and python package will be installed into editor.

    Verify Python Autocomplete and Build

    To verify python support, again restart the IDE. Create a file with name demo.py . Type few simple commands like print . It should open the autocomplete window.

    Now type simple hello world code, and enter CTRL + B in keyborad. It will open the output output window in bottom pane and will show the build output of the commands in the demo.py file.

    Sublime Build Output

    Now you are ready to create and build python programs using sublime editor.

    Источник

Оцените статью