IntelliJ IDEA - Multiple Pockets?

Sometimes I have to write a Java class where I need to define several fields of the same type. For example, I know that I will need to duplicate a private final String on the next 4 lines.

Is it possible that several carriages appear in the IntelliJ editor, so I can type several lines at a time?

+6
source share
4 answers

I think the "Column Select Mode" may help you. You can enable it in the context menu in the editor. Then you can select multiple lines and enter the same text at the same time. Here is a tutorial on how it works.

+5
source

IntelliJ IDEA 14.1 and 15

You can press Alt + Shift and using a left click , you can put many carriages.

eg:.

long caret 1

will become

long caret 2

input is "added" only once.

If you want to have a continuous vertical line , just press Alt + drag vertically . If there are lines with a length shorter than the current position, the vertical line will be broken (carriages will be placed at the end of each line) if "Allow carriage after line ends" is disabled (in the menu "File"> "Settings") ... > Editor> General> Virtual Space).

Another way to add a continuous vertical line is to press Ctrl twice and then press the up or down arrow key (supported in JetBrains 2016.X products and, possibly, earlier).

Cm

+6
source

Add / Remove Carriage: Alt + Shift + Mouse Click

Delete all clips: Esc

0
source

Column selection

On Windows, you can use CTRL + CTRL (Hold) + ↑ / ↓ . For Mac, replace CTRL with .

Change hotkey "Multi-Caret"

To add a custom Keymap, CTRL + SHIFT + A , enter keymap and click on Settings as a subtext. Find Clone Caret Above and Clone Caret Below .

I matched mine with ALT + SHIFT + ↑ / ↓ .

Bonus

Try using the CTRL , SHIFT, and arrow combinations to improve the power of selection.

0
source

Source: https://habr.com/ru/post/952100/


All Articles