


Detailed graphic and text explanation of the steps to set up Sublime Text's Python development environment
Recently, when I mainly use the Python development environment to edit, I have begun to use Sublinme Text 2 more and more. This article mainly explains how to make Python programmers more convenient to use some settings and adjustments.
Why choose Sublime Text?
I have always been a loyal user of TextMate. This is a lightweight, open source software that comes as a native OS X application with a nice Mac feel. However, although TextMate is a great editor, it sometimes lacks functionality.
I have used some more powerful software, such as IntelliJ IDEA with Python plug-in. I particularly like its debugger and test runner. However, a full-featured IDE like IntelliJ is still too large for small and medium-sized projects.
In recent weeks I have started using Sublime Text more and more. Once I installed it, it felt really good. It's really fast, updates automatically and regularly, and best of all, it's fully cross-platform. For me, where it ultimately beats TextMate is Sublime's powerful plugin subsystem. For Python development, there are many plug-ins that can make your development smoother and more fun.
I still switch editors between different projects. However, I found that for Python development, Sublime has a good balance between a lightweight editor and a full-featured IDE.
Font selection
Ubuntu Mono is a very, very good font. I just switched from Menlo a few days ago and I definitely don’t regret it.
On my 15-inch MacBook, Ubuntu Mono’s 16-point font fits perfectly. The resolution of 1680 × 1050 is just right for a sidebar plus two editor windows (which automatically adjust to 80 characters wide).
If you plan to carefully choose a font, this article from slant.co is well written. It contains screenshots and download links for most popular programming fonts.
Install plug-ins
As mentioned before, Sublime has a very rich plug-in system. The plug-ins I currently use are as follows:
Package Control The package manager for installing additional plug-ins directly in Sublime. This is the only plugin you have to install manually. All other plugins listed here can be installed via Package Control. You can also use it to update installed plug-ins. It's as simple as apt-get for Sublime packages.
Color Scheme - Tomorrow Night Color schemes determine the font color for syntax highlighting in the editor interface. This is a very cool dark style.
Theme - Soda Dark Themes affects the color and style of Sublime interface elements. This is a perfect color scheme for Tomorrow Night.
SideBarEnhancements This plug-in provides additional context menu options for the sidebar, such as "New file", "New Floder", etc. These should be there by default, but they are not.
All Autocomplete Sublime's default autocomplete only focuses on words in the current file. This plugin extends its autocomplete word list to all open files.
SublimeCodeIntel enhances the auto-complete function for some languages, including Python. This plugin also allows you to jump to where a symbol is defined by holding down alt and clicking on the symbol. Very convenient.
SublimeREPL allows you to run the Python interpreter directly in the editing interface. I prefer running bpython in a separate terminal window, but sometimes SublimeREPL can be helpful.
GitGutter In the groove area of the editor, according to Git, add a small icon to identify whether a line is inserted, modified or deleted. The GitGutter readme explains how to change the color icons to update your color scheme file.
Pylinter This plug-in provides the best pylint editor integration I have seen so far. It automatically checks .py files whenever they are saved and displays pylint violations directly in the editing interface. It also has a shortcut to disable local pylint checking, by inserting a #pylint: disable comment . This plugin is really useful for me.
Configuration file
One of the advantages of Sublime Text is that all its configurations are simple configurations based on JSON document. This allows you to easily transfer the configuration to another system. I've also seen some people use Dropbox to automatically sync their configuration across all their computers.
Preferences.sublime-settings configures the display and behavior of Sublimede. You can open and edit this file in sublime through Preferences > Settings — User. I configured the pylinter plug-in using the following configuration:
{ // Colors "color_scheme": "Packages/Tomorrow Color Schemes/Tomorrow-Night.tmTheme", "theme": "Soda Dark.sublime-theme", // Font "font_face": "Ubuntu Mono", "font_size": 16.0, "font_options": ["subpixel_antialias", "no_bold"], "line_padding_bottom": 0, "line_padding_top": 0, // Cursor style - no blinking and slightly wider than default "caret_style": "solid", "wide_caret": true, // Editor view look-and-feel "draw_white_space": "all", "fold_buttons": false, "highlight_line": true, "auto_complete": false, "show_minimap": false, // Editor behavior "scroll_past_end": false, "highlight_modified_tabs": true, "find_selected_text": true, // Word wrapping - follow PEP 8 recommendations "rulers": [ 72, 79 ], "word_wrap": true, "wrap_width": 80, // Whitespace - no tabs, trimming, end files with \n "tab_size": 4, "translate_tabs_to_spaces": true, "trim_trailing_white_space_on_save": true, "ensure_newline_at_eof_on_save": true, // Sidebar - exclude distracting files and folders "file_exclude_patterns": [ ".DS_Store", "*.pid", "*.pyc" ], "folder_exclude_patterns": [ ".git", "pycache", "env", "env3" ] }
Pylinter.sublime-settings. I use the following configuration to have Pyhton automatically normalize on save and display icons for violations.
{ // Configure pylint's behavior "pylint_rc": "/Users/daniel/dev/pylintrc", // Show different icons for errors, warnings, etc. "use_icons": true, // Automatically run Pylinter when saving a Python document "run_on_save": true, // Don't hide pylint messages when moving the cursor "message_stay": true }
Key binding
Sublime’s key bindings are also fully configurable based on the JSON-based sublime-keymap configuration file. I modified some of the default configuration to better suit my TextMate / IntelliJ muscle memory. You don't have to modify it at all. It's easy to modify and can be used cross-platform if you want. I use the following binding:
[ // Rebind "go to file" to cmd+shift+O { "keys": ["super+shift+o"], "command": "show_overlay", "args": { "overlay": "goto", "show_files": true }}, // Rebind swap line up/down to cmd+shift+up/down { "keys": ["super+shift+up"], "command": "swap_line_up" }, { "keys": ["super+shift+down"], "command": "swap_line_down" }, // Delete a line with cmd+delete { "keys": ["super+backspace"], "command": "run_macro_file", "args": { "file": "Packages/Default/Delete Line.sublime-macro" }}, // Reindent selection with cmd+alt+L { "keys": ["super+alt+l"], "command": "reindent"} ]
Command Line Tool
Similar to TextMate's mate, Sublime Text includes a command line tool that allows you to open the editor through a shell. The tool is called sublis and is not available by default. To take effect, run the following in any shell:
ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl
To use Sublime as the default editor for interactive git commands - for example, writing commit messages - just add the following line to your ~/.profile file:
export GIT_EDITOR="subl --wait --new-window"
The above is the detailed content of Detailed graphic and text explanation of the steps to set up Sublime Text's Python development environment. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



It is impossible to view MongoDB password directly through Navicat because it is stored as hash values. How to retrieve lost passwords: 1. Reset passwords; 2. Check configuration files (may contain hash values); 3. Check codes (may hardcode passwords).

You can learn basic programming concepts and skills of Python within 2 hours. 1. Learn variables and data types, 2. Master control flow (conditional statements and loops), 3. Understand the definition and use of functions, 4. Quickly get started with Python programming through simple examples and code snippets.

Python is widely used in the fields of web development, data science, machine learning, automation and scripting. 1) In web development, Django and Flask frameworks simplify the development process. 2) In the fields of data science and machine learning, NumPy, Pandas, Scikit-learn and TensorFlow libraries provide strong support. 3) In terms of automation and scripting, Python is suitable for tasks such as automated testing and system management.

As a data professional, you need to process large amounts of data from various sources. This can pose challenges to data management and analysis. Fortunately, two AWS services can help: AWS Glue and Amazon Athena.

The steps to start a Redis server include: Install Redis according to the operating system. Start the Redis service via redis-server (Linux/macOS) or redis-server.exe (Windows). Use the redis-cli ping (Linux/macOS) or redis-cli.exe ping (Windows) command to check the service status. Use a Redis client, such as redis-cli, Python, or Node.js, to access the server.

To read a queue from Redis, you need to get the queue name, read the elements using the LPOP command, and process the empty queue. The specific steps are as follows: Get the queue name: name it with the prefix of "queue:" such as "queue:my-queue". Use the LPOP command: Eject the element from the head of the queue and return its value, such as LPOP queue:my-queue. Processing empty queues: If the queue is empty, LPOP returns nil, and you can check whether the queue exists before reading the element.

Question: How to view the Redis server version? Use the command line tool redis-cli --version to view the version of the connected server. Use the INFO server command to view the server's internal version and need to parse and return information. In a cluster environment, check the version consistency of each node and can be automatically checked using scripts. Use scripts to automate viewing versions, such as connecting with Python scripts and printing version information.

Navicat's password security relies on the combination of symmetric encryption, password strength and security measures. Specific measures include: using SSL connections (provided that the database server supports and correctly configures the certificate), regularly updating Navicat, using more secure methods (such as SSH tunnels), restricting access rights, and most importantly, never record passwords.
