IDEA: “Assign statement to new local variable”?

后端 未结 3 366
孤城傲影
孤城傲影 2020-12-28 12:49

As a long time Eclipse user, I\'m playing around a little bit with IntelliJ IDEA 10. I can\'t seem to find out how to perform an \"Assign statement to new local variable\" c

3条回答
  •  囚心锁ツ
    2020-12-28 13:32

    As CrazyCoder mentions you can use Ctrl+Alt+V. Also instead of selecting the expression, clicking into somewhere in your expression and using Ctrl+W to expand scope is very useful while using introduce refactorings. Extract refactorings are:

    • Extract variable: Ctrl+Alt+V
    • Extract field: Ctrl+Alt+F
    • Extract method: Ctrl+Alt+M
    • Extract parameter: Ctrl+Alt+P
    • Extract constant: Ctrl+Alt+C

    Also, Idea is a polygot editor so you can use these extract refactorings for other file types like js or html also (not all refactorings work in all file types but Ctrl+W works mostly).

    There are more extract refactorings which do not have shortcuts which you can access from Refactor|Extract menu (both menu bar and context menu). To quick access all refactorings you can use Ctrl+Alt+Shift+T for a popup menu.

    As a last word, I highly encourage you using "Tip of the Day" (Help|Tip of the Day). It is a fast way to learn many helpful features of Idea.

提交回复
热议问题