Minor editor features
Noctule provides several minor but useful editor features that help you work with Swift code.
Code folding
Code folding allows hiding or collapsing sections of Swift code.
Automatic code folding
Noctule supports automatic code folding. The settings are available at Preferences → Editor → General → Code Folding .
- Imports
- Noctule automatically folds imports if you enable the generic setting of your IDE at Fold by default → General → Imports on the folding page.
- Multi-line comments
- Noctule automatically folds multi-line comments if you enable the setting at Fold by default → Swift (Noctule) → Multiline comments .
- Method bodies
- Noctule automatically folds the blocks of method declarations if you enable the setting Fold by default → General → Method bodies on the folding page.
Expand macro
Since Noctule 4.0To see the code that a Swift macro generates, place the caret on the macro, e.g. @Observable or #Preview,
press
Alt →
Enter
and choose “Expand Macro”.
The expanded code is shown in a popup, and macros in the expanded code can be expanded further.
The expansion is computed by SourceKit-LSP and doesn’t change your code.
Duplicated code fragments
Paid feature Since Noctule 4.0
Swift and Objective-C support the inspection “Duplicated Code Fragment” of the paid JetBrains IDEs, e.g. IntelliJ IDEA Ultimate. It finds code that was copied and pasted, even if the names of variables differ.
Noctule integrates with your IDE’s inspection Preferences… → Editor → Inspections → General → Duplicated Code Fragment , which detects duplicate fragments in your project. Please refer to JetBrains’ manual page on duplicated code to learn how to use the inspection.
Join lines
Edit → Join Lines automatically inserts a semicolon when you join two or more lines containing statements.
Automatic insertion of quotes
If you enter the beginning of a simple or a multi-line string literal, the matching end is automatically inserted.
For example, typing " turns this into "" and entering #""" automatically inserts """# on a new line.
Escape handling for copy & paste
If the setting Editor → General → Smart Keys → Swift → Escape text on paste in string literals is enabled, Noctule automatically escapes text you paste into a string literal. It also unescapes text you copy from a string literal.
Code author Code Vision
The author retrieved from Git is shown next to type declarations, functions, methods, initializers and deinitializers. This integrates with the Author Code Vision settings of the IDE, which are explained here in JetBrains’ online documentation.
Focus mode
Noctule integrates with Preferences… → Editor → General → Appearance → Highlight only the current declaration . If this setting is enabled, then only the current declaration is highlighted as usual in the editor; other declarations are shown in a dimmed color.