1

Is it possible to mark multiple lines in PhpStorm?

e.g.

LineA
LineB
LineC

lets say I try to mark LineA and LineC to copy paste them to another place, is this possible?

LineA
LineC
Black
  • 18,150
  • 39
  • 158
  • 271

2 Answers2

3

Use multiple cursors. The keyboard shortcuts may vary (those described in the documentation do not work for me on Linux).

Explore clicking around the text while various combinations of the Ctrl, Alt and Shift keys are pressed. On macOS also try Cmd. One of them allows you to place multiple carets in the text (f.e. at the beginning of the lines you want to copy).

After you placed all the carets you need use Shift and the arrows to extend the selection. Use Copy and Paste as usual. Use Escape or click anywhere in the text to deselect and go back to the regular, single-caret, status.

axiac
  • 68,258
  • 9
  • 99
  • 134
3

Sure .. but it requires a bit of "precision pointing" and using mouse (not sure if it's easily doable with keyboard only).

Basically -- the idea is to use Multiple Carets functionality:

  1. Place caret at the beginning of first line
  2. Now Alt + Click on the beginning of the other line to create new caret there (shortcut depends on OS -- on Linux it might be different shortcut/combo as that shortcut may used by Desktop/Window manager for own stuff)
  3. Now you have 2 carets on the beginning of Line A and Line C
  4. Just use Shift + End to select text to the end of line -- it will be done in both lines.
  5. Now just Copy + Paste it elsewhere (or whatever you wanted to do).
  6. Use Esc to get rid of carets.
LazyOne
  • 158,824
  • 45
  • 388
  • 391
  • Thanks, I will try it as soon as I know the correct shortcut for linux. – Black Mar 29 '17 at 09:26
  • @Black this is the wrong approach. The correct approach is to try it until you find the correct shortcut for Linux. It works with `Ctrl-Alt-Shit-click` for me. – axiac Mar 29 '17 at 09:36
  • 1
    @Black Well -- just check (and change if needed) what shortcut is associated with `Editor Actions | Add or Remove Caret` action in `Settings/Preferences | Keymap` – LazyOne Mar 29 '17 at 10:37