Intellij CheatSheet
Intellij editors cheatsheet. IDEA, GoLand, WebStorm, PyCharm, etc.
Select File in Project View
Allow you to highlight and select the file in editor in the project view sidebar.
Useful when have the file open but the folders closed in project view.
There is no default shortcut for this action, so I normally set it to Alt + 0
In Settings > Keymap
, under Other > Bookmarks -> Select File in Project View
.
Editor Tabs
Show tabs in multiple rows: Settings > Editor > General > Editor Tabs > Apperance > Show tabs in:
change from the
default One row
to Multiple rows
.
Define custom folding regions
Use //region
and //endregion
to define custom folding regions in the code.
- https://intellij-support.jetbrains.com/hc/en-us/community/posts/4408142449042/comments/4408149442194
- https://www.jetbrains.com/help/idea/code-folding-settings.html#:~:text=Method%20bodies-,Custom%20folding%20regions,-%2D%20blocks%20of%20code
public class CommonFields {
//region Time Start
public static void timestamp(Field.FieldsBuilder builder, SchemaContext context, String name, String comment) {
MessageRef timestamp = new FirestoreTimestampModel(context).toMessage().reference();
builder.message(name, timestamp, comment);
}
/**
* All the firestore document has create and update time
*/
public static void createUpdateTime(Field.FieldsBuilder builder, SchemaContext context) {
MessageRef timestamp = new FirestoreTimestampModel(context).toMessage().reference();
builder.createdAt(timestamp)
.updatedAt(timestamp);
}
public static void startEndTimeDuration(Field.FieldsBuilder builder, SchemaContext context) {
MessageRef timestamp = new FirestoreTimestampModel(context).toMessage().reference();
builder.message("startTime", timestamp, "Start time of event in epoch milliseconds")
.message("endTime", timestamp, "End time of event in epoch milliseconds")
.integer("duration", "Duration of event in minute");
}
//endregion
}
File nesting base on extension
When using code generators in flutter, there will be foo.g.dart
and foo.freezed.dart
files. They take a lot of
spaces in the project view and are rarely viewed. Excluding those files from index would break the autocompletion.
The solution is to use File nesting rules
- Use the project view in the sidebar
- Click the three dot
- Select
File Nesting ...
- Add the rule. The syntax is
- Parent file:
.dart
- Child file:
.g.dart;.freezed.dart
- Parent file: