Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime-like multiple selection operations in IntelliJ IDEA

What I have is, I did a mistake

I aligned my tabular data like this

<tr>
  <td> first row </td>
  <td> second row </td>
  <td> third row </td>
</tr>

<tr>
  <td> first row </td>
  <td> second row </td>
  <td> third row </td>
</tr>

now to fix the mistake I want to copy the content of the second tr next to the first and enclose it with trs

e.g.

<tr>
  <td> first row </td>       <td> first row </td>
  <td> second row </td>      <td> second row </td>
  <td> third row </td>      <td> third row </td>
</tr>

then do this manually:

   <tr><td> first row </td>       <td> first row </td> </tr>
 <tr> <td> second row </td>      <td> second row </td></tr>
  <tr><td> third row </td>      <td> third row </td></tr>

is there a nicer way than doing it manually? I tried using ALT mode , but it would repeat everything, e.g. the whole copied block for each line.

like image 875
Toskan Avatar asked Dec 25 '22 14:12

Toskan


2 Answers

This can be done using IntelliJ's column selection mode. Press Ctrl+Shift+A (+Shift+A on Mac) and select Edit: Column selection mode. You can then select the second block of <td> elements, cut them, move the cursor spanning 3 lines to the first block and paste it after the original <td> elements.

Here is a gif illustrating the process:

enter image description here

like image 89
Bohuslav Burghardt Avatar answered Mar 16 '23 22:03

Bohuslav Burghardt


If Column Selection Mode is turned off, you should turn it on. It's in the Edit menu, about half way down. You can also turn it on (or off) with the keyboard shortcut Alt+Shift+Insert on Windows - not sure what the macOS equivalent is.

Once you turn on that mode, you just use Shift+ or Shift+ to add a cursor to the row above or below.

It's not quite the same as what you get with Sublime Text, but hopefully that's good enough to do whatever you want.

like image 28
ArtOfWarfare Avatar answered Mar 16 '23 21:03

ArtOfWarfare