Copy Python Import
Sublime Text package for easily copying Python import lines
Details
Installs
- Total 5
- Win 2
- Mac 1
- Linux 2
| Jul 5 | Jul 4 | Jul 3 | Jul 2 | Jul 1 | Jun 30 | Jun 29 | Jun 28 | Jun 27 | Jun 26 | Jun 25 | Jun 24 | Jun 23 | Jun 22 | Jun 21 | Jun 20 | Jun 19 | Jun 18 | Jun 17 | Jun 16 | Jun 15 | Jun 14 | Jun 13 | Jun 12 | Jun 11 | Jun 10 | Jun 9 | Jun 8 | Jun 7 | Jun 6 | Jun 5 | Jun 4 | Jun 3 | Jun 2 | Jun 1 | May 31 | May 30 | May 29 | May 28 | May 27 | May 26 | May 25 | May 24 | May 23 | May 22 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Windows | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Mac | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Linux | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Readme
- Source
- raw.githubusercontent.com
Copy Python Import
A Sublime Text 4 package.
Copies a full Python import statement for the symbol under cursor to the clipboard.
Supports:
- classes,
- functions,
- methods [1].
- module-global variables (sometimes called constants).
- modules [2].
[1]: For class methods, the import statement will point at a class, as importing methods directly is impossible.
[2]: Current module is selected whenever no other syntax element (from the list above) can be identified. Thus module is a fallback that always works.
Install
Via Package Control (recommended)
- Open Command Palette (Ctrl+Shift+P).
- Select Package Control: Install Package.
- Search for Copy Python Import and press Enter.
The package will be installed and kept up-to-date automatically.
Manual installation
[!NOTE] Use this if Package Control is not available in your setup.
First find your Sublime Text packages directory. You can use the built in command:
- Open Command Palette (e.g. Ctrl+Shift+P or Tools -> Command Palette in the menu.)
- Select Preferences: Browse Packages
- Copy the directory path from your file manager
(e.g.
~/.config/sublime-text/Packages/)
Now you have a few options to proceed.
With Git
- Open a shell and navigate to the aforementioned packages directory.
Run:
git clone git@github.com:odiroot/copy_python_import.git copy_python_import
The package is already installed and running.
[!NOTE] You can always update to the newest version by running
git pullfrom inside of thatcopy_python_importdirectory.
From a download
- Open the releases page.
- Download Source code (zip) for the newest release.
- Unpack the ZIP archive.
- Copy the
copy_python_import-masterdirectory to your Sublime Text package directory. - All done!
Usage
Navigate with your keyboard or mouse to move the cursor to a symbol you want to import.
Then either:
- Open the Command Palette and search for Copy Python Import.
- Right click to open the context menu and click Copy Python Import.
- Use a custom key binding (see Configuration).
Configuration
To comply with Sublime Text package guidelines, default key bindings are provided but disabled by default.
To enable or customize them:
- Go to Preferences → Package Settings → Copy Python Import → Key Bindings.
- Copy the suggested binding from the left pane (the default file) to the right pane (your user settings).
- Adjust the
keysif desired and save.
Example Key Binding
[
{ "keys": ["ctrl+alt+i"], "command": "copy_python_import" }
]
Disclaimer
Forked from pokidovea/copy_python_path