Smart Duplicate Line
- 2 minutes to read
You can copy a line using the Shift+Enter shortcut. CodeRush also helps you create structurally similar code lines with minimal changes. The main Smart Duplicate Line features are listed below.
- Increments/decrements all numeric values (decimal, float, double, hex, octal literals, and identifier parts) based on a recognized incrementation pattern.
- Increments/decrements single letter identifiers and their parts based on alphabetically-ordered duplication patterns.
- Creates text fields for the parts of the line that are expected to change. Recognizes camelCaseParts.
- Changes similar line parts simultaneously by creating linked text fields.
- Recognizes enum element references and automatically cycles through those elements (if an enum element cycling pattern is detected in the surrounding code).
- Creates a text field around each identifier and literal in a duplicated line if the Smart Duplicate Line cannot recognize a pattern.
- Parameters and Arguments in method declarations and calls can also be duplicated using Shift+Enter.
- You can duplicate string concatenation elements, bitwise, boolean and arithmetic expressions. CodeRush inserts a default operator and marks it with a text field so you can change it later.
Tips and Tricks
- You can disable the Duplicate Line's "smart" features. Open the IDE | Shortcuts options page, find and select the DuplicateLine command's shortcut (Shift+Enter by default), write "false" in the Parameters field and click OK.
- The last line or selection duplication is repeated if you invoke the Smart Duplicate Line at the end of the previously duplicated code. This enables you to duplicate a selection several times without re-selecting the code.
- Text fields can be defined manually before duplication using Multi-Select.
- Select the part(s) you need to change before duplicating a parameter to create only the required text fields. For example, you can select a parameter name and its type to change both, or just a name if the next argument's type should be the same.
- You can dismiss all text fields using the Esc key if Smart Duplicate Line generates unnecessary text fields.
Possible Uses
Enumerations description
Declarations
Structurally similar code lines
Color shadings declaration
See Also