IntelliJ IDEA: Move line?

Keyboard ShortcutsIntellij Idea

Keyboard Shortcuts Problem Overview


I really like IntelliJ IDEA's "Move statement" shortcut (Ctrl + Shift + /). However -- I am not sure if this is a bug releated to ActionScript editing only -- move statement is not always what I want and sometimes it is not correct when editing AS code.

So I just want to move a block of lines up/down. The Eclipse shortcut is Alt + / and does not move statement-wise. Is there an equivalent in IntelliJ IDEA?

Keyboard Shortcuts Solutions


Solution 1 - Keyboard Shortcuts

Open Setings -> Keymap then search for "move line" via the upper right searchbox.

Under the Code folder you'll see:

  • Move Statement Down
  • Move Statement Up
  • Move Line Down
  • Move Line Up

The actions you're looking for are (as you may guess) the move line actions.

Solution 2 - Keyboard Shortcuts

As other people have said this is already available as a command. You can configure the short cut to your liking, but by default (at least in IntelliJ 10) it is bound to ALT + SHIFT + and ALT + SHIFT +

Solution 3 - Keyboard Shortcuts

Solution 4 - Keyboard Shortcuts

Please find some useful shortcut for IntelliJ:


(1) IntelliJ Debugger

Step over (Go To next Step or line) : F8

Step into (Go into function) : F7

Smart step into : Shift + F7

Step out : Shift + F8

Run to cursor : Alt + F9

Evaluate expression : Alt + F8

Resume program : F9 [Mac = Cmd + ALT + R]

Toggle breakpoint : Ctrl + F8 [Mac = Cmd + F8]

View breakpoints : Ctrl + Shift + F8 [Mac = Cmd + Shift + F8]


(2) Open Specific File

Ctrl + Shift + N


(3) Open All Methods Implemented in class

Open specific class and press,

Ctrl + F12


(4) Go to Specific Line Number

Ctrl + G


(5) Method Implementation and Declaration

Declaration : Ctrl + B

Implementation : Ctrl + Alt + B

Response Type Declaration : Ctrl + Shift + B

Super class override Method : Ctrl + U


(6) Reformate Code

Ctrl + Alt + L


(7) Import relevant class

Click on relevant class (Red color field) and press,

Alt + Enter

Select valid class as per requirement


(8) Hierarchy of method calls

Select specific method and press,

Ctrl + Alt + H


(9) Comment In Code

Single Line : Select specific line and press, Ctrl + /

Multiple Line : Select Multiple Line and Press, Ctrl + Shift + /

(Note : Same operation for uncomment the code)


(10) Display Line Number

Hit Shift twice > write "line" > Show Line Numbers (the line doesn't have the toggle)

View > Active Editor > Show Line Number


(11) Code Selection

Full class selection : Ctrl + A Method Selection : Select Method Name and press, Ctrl + W


(12) Basic Code Completion

To complete methods, keywords etc press,

Ctrl + Space


(13) Code Copy and Paste

Copy : Ctrl + C

Paste : Ctrl + V


(14) Search Operation

Specific File : Ctrl + F

Full Project : Ctrl + Shift + F


(15) Switcher Popup

Open Switcher Popup : Ctrl + Tab

Continue press Ctrl and use ↑/↓/←/→ for move one place to another


(16) Forward Move & Backward Move

Backward : Ctrl + Alt + ← (Left-Arrow)

Forward : Ctrl + Alt + → (Right-Arrow)


(17) Next/previous highlighted error

F2 or (Shift + F2)


(18) Open Java Doc

Select specific method name and press,

Ctrl + Q


(19) Find All commands

Ctrl + Shift + A


(20) Move Line Up/Down

shift + alt + ↑/↓

Thanks...

Solution 5 - Keyboard Shortcuts

The LineMover plug-in works very well and is an acceptable solution.

Solution 6 - Keyboard Shortcuts

You can move several lines together with move statement. Are you trying to move partial lines? I don't think there's a way in Idea.

Solution 7 - Keyboard Shortcuts

try command+shift+up/down this will auto adjust the indentation

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJoa EbertView Question on Stackoverflow
Solution 1 - Keyboard ShortcutsKai ZimmerView Answer on Stackoverflow
Solution 2 - Keyboard ShortcutsslashnickView Answer on Stackoverflow
Solution 3 - Keyboard ShortcutsAbdul Rehman Kaim KhaniView Answer on Stackoverflow
Solution 4 - Keyboard ShortcutsRadadiya NikunjView Answer on Stackoverflow
Solution 5 - Keyboard ShortcutsJoa EbertView Answer on Stackoverflow
Solution 6 - Keyboard ShortcutsPanCritView Answer on Stackoverflow
Solution 7 - Keyboard ShortcutsSHAKUView Answer on Stackoverflow