The requested page is not available for the requested platform. You are viewing the content for Default platform.

Smart Duplicate Line

  • 2 min to read

The Smart Duplicate Line helps you create structurally similar code lines with minimal changes. This feature duplicates a code line and inserts text fields into the duplicate to simplify code modification. The Smart Duplicate Line can also change cloned values based on a detected pattern.

This feature works in C#, Visual Basic, XAML, and HTML code.

XAMLCode

How to Use

  • Place the caret in a code line you want to duplicate.

  • Press the Shift+Enter shortcut to copy the code.

SDL_Code

The Smart Duplicate Line creates text fields for the code line parts you can change. It also links identifiers used several times in the code. You can edit one identifier and all other identifiers reflect the changes.

Note

Use the Esc key to dismiss unnecessary text fields.

Features

Increment/Decrement Decimal, Float, Double, Hex, and Octal Literals

The Smart Duplicate Line increments/decrements decimal, float, double, hex, and octal literals if it detects an increment pattern.

Increment

Note

When the Smart Duplicate Line duplicates items in collection initializers and in parameter lists, it adds commas automatically, if needed.

Increment/Decrement Single Letter Identifiers Parts

The Smart Duplicate Line can increment/decrement single letter identifiers and their parts based on a detected alphabetical pattern in the code.

Identifier

Recognize Enum Element References and Cycle Through Elements

This feature recognizes enum element references and cycles through those elements if it detects an enum element cycling pattern in the surrounding code.

LinkedTextFields

CamelCase

To enable this functionality, check the following options in the Editor | All Languages | Linked Text & Fields options page:

  • Link matching text across different kinds of elements.
  • Include partial matches (camel case parts).

Camel

Duplicate Parameters and Arguments in Method Declarations and Calls

You can declare new parameters based on the selection and existing parameters.

Args

Options

You can configure how CodeRush generates links and fields in the Editor | All Languages | Linked Text & Fields options page. The screenshot below shows the default options.

LinkedTextFields

Change the Default Shortcut

You can change the default Shift+Enter shortcut for the DuplicateLine command in the IDE | Shortcuts options page.

Shortcut

  • Find the DuplicateLine command's shortcut (Shift + Enter) and select it.

  • Change the First shortcut text field and press OK to apply this change.

See Also