[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Collapse]CodeRush
  System Requirements
  Improve Performance
 [Expand]Features by Language
 [Expand]Getting Started
 [Expand]How To
 [Collapse]Coding Assistance
  [Expand]Code Templates
  [Expand]Auto Completion
  [Expand]Clipboard Tools
  [Expand]Selection Tools
  [Expand]Code Providers
  [Expand]Declare Menu
  [Collapse]Typing Helpers
    Smart Duplicate Line
    Smart Duplicate Selection
    Mega Super Copy
    Cycle Scope Up/Down
    Smart Semicolon
    Expand/Collapse Regions
    Region Creation
 [Expand]Navigation and Search Tools
 [Expand]Static Code Analysis
 [Expand]Visualization Tools
 [Expand]Code Style Assistance
  Building Assistance
  Debugging Assistance
 [Expand]Refactoring Assistance
 [Expand]Unit Testing Assistance
 [Expand]Decompiling Tools
 [Expand]Configuration Options
 [Expand]Extensibility
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Smart Duplicate Line

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.

Expanded How to Use

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

  • Press the Shift+Enter shortcut to copy the 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.

Expanded 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.

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.

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.

Recognize Camel Case Parts of Identifier Name and Link Identifiers Similar Parts

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).

Duplicate Parameters and Arguments in Method Declarations and Calls

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

Expanded 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.

Change the Default Shortcut

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

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

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

Expanded See Also

Is this topic helpful?​​​​​​​