Table of contents
Foreword
IntelliJ IDEA contains uncountable number of features and most of them are unknown to the end-users. I'm going to talk about one of them that is quite useful under some circumstances.
Column mode editing
It's rather often that we want to perform similar action on a number of subsequent lines. For example we may have a private static class that was used internally and holds data at public final fields. Let's imagine that we want to make it public and change fields visibility from 'public' to 'private' and provide corresponding getters. The later can be done quickly via 'generate getters' feature and the former can be achieved by the following:
- Select target modifiers at column mode;
- Type 'private';
Here is a small video that illustrates that:
It's also possible to perform column selection by left mouse button holding Alt. In example below we have a newly introduced method that overloads existing one and uses default value as the one of the arguments. Javadoc stub is generated by IntelliJ and we want to copy description from the remained parameters. The algorithm is pretty simple:
- Copy target parameters description at 'column mode';
- Start column mode in a place where we want to perform 'paste';
- Perform paste;
One more use-case - copying to external application. IntelliJ IDEA provides 'Reformat on paste' feature that automatically adapts pasted text to the current context. However, that is not the case for external applications. So, we can select the text at column mode in order to avoid unnecessary indentation then:

0 comments:
Post a Comment