Skip to content

how to quickly add import xxx to top #930

Closed

Description

@eromoe

It is usually inconvenient to add import xxx .

For example,
I want import numpy as np
I need go to top, add it under

# -*- coding: utf-8 -*-
# @Author: mithril

from __future__ import unicode_literals, print_function, absolute_import, division

import xxx
from xxx import xxx
import numpy as np  

Then go back to original position , is there any quick way to do this ?

Activity

  1. brettcannon commented on Mar 2, 2018

    @brettcannon
    Member

    As this is a question, this should go on Stack Overflow at the link provided in the issue template so I'm closing this.

    But to quickly answer the question, the answer is there isn't a current way but #636 would implement this if/when we merge that PR (this is also a duplicate of #21 ).

  2. balta2ar commented on May 15, 2018

    @balta2ar

    Brett Cannon (@brettcannon) Looks like this feature is already available for TypeScript: microsoft/vscode#21764
    Could you please rename this issue into a feature request and reopen? I can create a separate issue if that's the preferred way to track it.
    Please note that "Auto import" or "Optimize imports" (using isort, for example) is not a substitution for this feature because there could be ambiguous imports, and only developer knows which one is best, thus a quickfix action functionality is necessary.

  3. brettcannon commented on May 15, 2018

    @brettcannon
    Member

    Yuri Bochkarev (@balta2ar) if we implement this it will be through a quickfix/lightbulb anyway and not a magical "insert without asking" type of solution.

  4. balta2ar commented on May 15, 2018

    @balta2ar

    Brett Cannon (@brettcannon) Sure! This is exactly what I meant, some kind of a menu with possible import alternatives should be displayed to the user.

  5. locked as resolved and limited conversation to collaborators on Jul 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions