36 ms·
Any kind of repetitive task :-) One example (from C++, so maybe not relevant for IntelliJ) I use them for is converting enums to a case statement. e.g. if I h
by imron 11y ago
Any kind of repetitive task :-)
One example (from C++, so maybe not relevant for IntelliJ) I use them for is converting enums to a case statement.
e.g. if I have:
typedef enum
{
VALUE_1,
VALUE_2,
VALUE_3,
...
VALUE_10
} MyEnum;
I can copy/paste lines from VALUE_1 through to VALUE_10, and then start recording a macro as I change
VALUE_1,
to
case VALUE_1:
break;
Adding a final 'j' to move down a line before finishing the macro.
Then I just run the macro several times and each line gets converted.
That's a pretty simple case (hah), there are plenty of other (and more complicated) uses for them too.
- cletus 11y agoI can't speak for CLion or the C++ plugin but in Java in IntelliJ you type: switch (enumVar) hit alt-enter and it gives you the option of filling in the missing branches. This even applies to partial switch statements missing some of the cases.
- Nullabillity 11y agoYou don't need macros for that, since IntelliJ has multi-cursor editing these days.