ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Copy Python Import

by odiroot ST4 New

Sublime Text package for easily copying Python import lines

Details

  • 0.3.3
  • github.​com
  • 4 hours ago
  • 34 minutes ago
  • 5 hours ago

Installs

  • Total 0
  • Win 0
  • Mac 0
  • Linux 0
May 21 May 20 May 19 May 18 May 17 May 16 May 15 May 14 May 13 May 12 May 11 May 10 May 9 May 8 May 7 May 6 May 5 May 4 May 3 May 2 May 1 Apr 30 Apr 29 Apr 28 Apr 27 Apr 26 Apr 25 Apr 24 Apr 23 Apr 22 Apr 21 Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7
Windows 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 0 0 0 0 0
Mac 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 0 0 0 0 0
Linux 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 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)

  1. Open Command Palette (Ctrl+Shift+P).
  2. Select Package Control: Install Package.
  3. 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:

  1. Open Command Palette (e.g. Ctrl+Shift+P or Tools -> Command Palette in the menu.)
  2. Select Preferences: Browse Packages
  3. Copy the directory path from your file manager (e.g. ~/.config/sublime-text/Packages/)

Now you have a few options to proceed.

With Git

  1. Open a shell and navigate to the aforementioned packages directory.
  2. Run:

    git clone git@github.com:odiroot/copy_python_import.git copy_python_import
    
  3. The package is already installed and running.

[!NOTE] You can always update to the newest version by running git pull from inside of that copy_python_import directory.

From a download

  1. Open the releases page.
  2. Download Source code (zip) for the newest release.
  3. Unpack the ZIP archive.
  4. Copy the copy_python_import-master directory to your Sublime Text package directory.
  5. All done!

Usage

Navigate with your keyboard or mouse to move the cursor to a symbol you want to import.

Then either:

  1. Open the Command Palette and search for Copy Python Import.
  2. Right click to open the context menu and click Copy Python Import.
  3. 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:

  1. Go to PreferencesPackage SettingsCopy Python ImportKey Bindings.
  2. Copy the suggested binding from the left pane (the default file) to the right pane (your user settings).
  3. Adjust the keys if desired and save.

Example Key Binding

[
    { "keys": ["ctrl+alt+i"], "command": "copy_python_import" }
]

Disclaimer

Forked from pokidovea/copy_python_path