150

Is it possible to some how setup IntelliJ IDEA so that I can column select with the cursor keys similarly to how I might in Notepad++, Visual Studio, or FlashDevelop.

For instance when I'm typing code I almost always do my navigation solely through use of the keyboard. In the IDEs mentioned previously I can quickly select blocks of code by holding Shift + Alt then tapping to extend my cursor across the lines above. I can then hold Shift + Alt + Ctrl and tap or to quickly jump across words and select the chunk of text I want.

In IntelliJ IDEA I have to constantly enable and disable Column Selection Mode using the Shift + Alt + Insert and even then it doesn't quite function as it does in the other IDEs or Text Editors.

Any ideas?

Gibolt
  • 42,564
  • 15
  • 187
  • 127
jshbrntt
  • 5,134
  • 6
  • 31
  • 60
  • 1
    This **[blog post](http://blog.jetbrains.com/idea/2014/03/intellij-idea-13-1-rc-introduces-sublime-text-style-multiple-selections/)** should be helpful. – Anton Dozortsev Oct 17 '14 at 18:12

10 Answers10

212

You can do column editing using the Edit | Column Selection Mode.

The shortcut to turn it on/off is Alt+Shift+Insert. You navigate with arrow keys to select blocks of text.

Anton Dozortsev
  • 4,782
  • 5
  • 34
  • 69
duffymo
  • 305,152
  • 44
  • 369
  • 561
  • 4
    I was aware of this mode but it didn't quite provide what I wanted, but it looks like I won't get the desired behavior without writing a plugin myself. – jshbrntt Dec 31 '14 at 12:46
  • 43
    On Mac the shortcut is Cmd+shift+* – 8bitme Mar 03 '16 at 09:56
  • 7
    For some reason on my Mac, Cmd+Shift+8 did not work and I could not figure out why, I remapped that to Control+Option+Command+8 and it worked fine. I also could not find anything that would prevent that old keymap from working other than possibly a system mapping which overrode it. – AlexC Aug 12 '16 at 15:13
  • This is the easiest. No need to try out weird combinations of keys – Karthik Apr 26 '17 at 20:44
  • 8
    It's like you didn't even read the question. @JoshuaBarnett Gibolt's answer is what you want. – jv110 Jul 12 '18 at 18:37
  • 2
    Seconding jv110 and his objection to JoshuaBarnett's answer. The poster is clearly aware already of the keyboard shortcut JoshuaBarnett mentions and is looking for a more lightweight way of entering column-editing mode, which is what @Gibolt's answer provides. – Daniel Cotter May 07 '19 at 00:06
92

Multiline Caret (without mouse)

Windows/Linux: CTRL + CTRL(Hold) + ↑ / ↓

Mac: + (Hold) + ↑ / ↓

ESC will end multiline mode.

Change Multi-caret Hotkey

To add a custom Keymap, CTRL+SHIFT+A, type keymap and click on the one with Settings as subtext. Search for Clone Caret Above and Clone Caret Below.

I mapped mine to ALT+SHIFT+↑ / ↓.

Bonus

Try holding combinations of CTRL, SHIFT, and arrows for improved selection power.

Community
  • 1
  • 1
Gibolt
  • 42,564
  • 15
  • 187
  • 127
  • 8
    I believe this should be the correct answer. The accepted answer currently just restates some of the content of the question—but this answer provides true rectangular selection without using the mouse, a la Notepad++. – Corwin Newall May 08 '18 at 01:23
  • 15
    On my Mac, the `ALT` key was mapped by default instead of `⌘`. So it was: `ALT` + `ALT` (Hold) + `↑` / `↓` – gfullam Jul 09 '18 at 17:16
  • You can't just state Windows and macOS and ignore Linux! – jv110 Jul 12 '18 at 18:39
  • @jv110 true. It's ok to state just `macOS` but can't put 'doze in front of 'nix – WestCoastProjects Mar 06 '20 at 22:31
66

It is also possible to select holding middle mouse key.

kyb
  • 7,233
  • 5
  • 52
  • 105
20

Most convenient way is to:

  • MAC: Hold Option+Shift and click with mouse.
  • Windows: Hold Alt and click with mouse.
Community
  • 1
  • 1
lukyer
  • 7,595
  • 3
  • 37
  • 31
19

Go to the Settings | Keymap and set a shortcut for Clone Caret Above and for Clone Caret Below

Meo
  • 12,020
  • 7
  • 45
  • 52
  • 1
    Do you know if it's possible to have it function similar to that of text editors such as Notepad++ where you can only extend in one direction and the opposite of that direction shrinks it? – jshbrntt Aug 07 '15 at 07:46
  • I do not think it is possible. I have not even seen a feature request for that. – Meo Aug 07 '15 at 09:24
  • Press Ctrl, then hold Ctrl, it's exactly like you described. – jv110 Jul 12 '18 at 18:41
  • that was the only solution that works for me. thanks for sharing. – devmarkpro Apr 06 '20 at 15:53
17

On a mac, to toggle block select on/off:

shift command 8

8

Bohemian
  • 412,405
  • 93
  • 575
  • 722
14

For me on Mac:

Press once 'option' key, release it, and press and hold it again. Now navigate with cursor to select desired code. Press 'Esc' to exit column mode! :)

LeXav
  • 141
  • 1
  • 3
11

I think @Meo's answer is the most correct, but if your hand happens to be on the mouse, you can also accomplish this with Ctrl+Alt+Shift+Left Mouse Button Click. Or look for the Add Rectangular Selection on Mouse Drag in the keymap settings.

Wesley Musgrove
  • 574
  • 5
  • 8
11

In Windows or Linux I press two times Ctrl

Carlos Verdes
  • 3,037
  • 22
  • 20
  • 2
    Click `Ctrl` then quickly press and hold `Ctrl` a second time. Use arrow keys while holding `Ctrl` to add carets/select – olejorgenb Apr 30 '18 at 14:41
1

For Mac cmd+shift+* didn't work for me. I changed the keymap to something else and now it works seamlessly.

sia
  • 537
  • 1
  • 6
  • 22