Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alecthomas/sublimepythonimportmagic
This Sublime Text 2 plugin attempts to automatically manage Python imports.
https://github.com/alecthomas/sublimepythonimportmagic
Last synced: 16 days ago
JSON representation
This Sublime Text 2 plugin attempts to automatically manage Python imports.
- Host: GitHub
- URL: https://github.com/alecthomas/sublimepythonimportmagic
- Owner: alecthomas
- Created: 2014-03-07T09:47:51.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-12-02T01:45:30.000Z (12 months ago)
- Last Synced: 2024-10-10T16:06:23.090Z (about 1 month ago)
- Language: Python
- Size: 1.13 MB
- Stars: 34
- Watchers: 7
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Sublime Text 3 - Python Import Magic [![image](https://secure.travis-ci.org/alecthomas/SublimePythonImportMagic.png?branch=master)](https://travis-ci.org/alecthomas/SublimePythonImportMagic)
This plugin attempts to automatically manage Python imports.
**WARNING: This is a relatively complex plugin and thus may contain bugs. It may remove imports that you need. It may add imports that you don't. Use at your own risk.**
It can:
- Detect and add imports for unknown symbols.
- Remove unused imports.
- Order imports according to PEP8.It currently does **NOT** (but support is planned):
- Detect changes to files and update its index automatically. The current workaround is to use the command palette `Python Import Magic: Reset Index`.
## Example
![Example of Import Magic at work](https://raw.githubusercontent.com/alecthomas/importmagic/master/importmagic.gif)
## Usage
There are three ways of invoking the auto-importer:
- The hotkey: `⌘⇧I` on OSX and `^⇧I` on Windows and Linux.
- Via the command palette: `Python Import Magic: Update Imports`.
- Setting `update_imports_on_save` to `true` in the user settings for the package. *I would not encourage use of this setting at this stage, but if you're feeling particularly brave...*## Configuration
eg.
```json
{
"update_imports_on_save": true,
"python_path": {
"/Library/Python/2.7/site-packages": "S",
"/Users/alec/Projects/SublimePythonImportMagic/.venv/lib/python2.7/site-packages": "L"
}
}
```### `update_imports_on_save = false`
If true, update imports on each save. **WARNING: This might not be a good idea.**
### `index_filename = ".importmagic.idx"`
Name of file to store index in.
### `python_path = {: }`
**NOTE: Not implemented yet**
Keys are the paths to search for Python modules. Values are how the path should be classified.
Paths will also be looked up in the default Sublime configuration under the key `python_import_magic_python_path`.
`` is from the following table:
Key | Classification
--- | -------
3 | Third party
S | System
L | Local