Clipboard Tools – Intelligent Paste
The CodeRush Intelligent Paste clipboard feature modifies the text from the clipboard before inserting it into the code editor. An action hint with the name of the expansion appears once the suitable expansion is triggered on the Paste (Ctrl+V) command.
For example, copying a field member into a clipboard and then pasting it on the next line will produce a read-write property for the field:
Before:
private int myValue;
After:
Another example is when copying simple method invoke expression (method call), the entire void method declaration will be pasted with markers:
Before:
ProcessMyValue();
After:
To execute Intelligent Paste, simply perform a usual Paste command bound to Ctrl+V or Shift+Insert shortcuts preceded by copying a piece of code with a structure defined as an Intelligent Paste expansion. The list of such expansions can be found on the Editor | Clipboard | Intelligent Paste options page in the Options Dialog. Intelligent Paste is fully extensible through the options page, and lets you specify the precise conditions that trigger the particular extension.
Here’s the list of built-in CodeRush Intelligent Paste expansions for CSharp language. Most of these expansions are also defined for Visual Basic and C++ languages. Of course, you can easily add new expansions to any supported language. Note that you can use DXCore text commands inside expansions.
Name |
Description |
Assignment | Converts a relational expression (e.g., “xxx < yyy”) to an assignment (e.g., “xxx = yyy”). |
Color Field from HTML | Converts an HTML color string (e.g., “#FF0000”) to a new color instance (e.g., “Color.FromArgb(0xFF, 0x00, 0x00)”). |
Color from HTML | Converts an HTML color string (e.g., “#FF0000”) to a new color instance (e.g., “Color.FromArgb(0xFF, 0x00, 0x00)”). |
Color from HTML (alpha=FF) | Converts an HTML color string (e.g., “#FFAA0000”) to a new color instance (e.g., “Color.FromArgb(0xAA, 0x00, 0x00)”). |
Color from HTML (with alpha) | Converts an HTML alpha-blended color string (e.g., “#80AA0000”) to a new color instance (e.g., “Color.FromArgb(0x80, 0xAA, 0x00, 0x00)”). |
Color Local from HTML | Converts an HTML color string (e.g., “#FF0000”) to a new color instance (e.g., “Color.FromArgb(0xFF, 0x00, 0x00)”). |
Create New | Converts a field declaration (e.g., “private Hashtable myTable;”) into code that constructs an instance of that identifier (e.g., “myTable = new Hashtable();”) when pasted on an empty line inside a method or property. |
Create New (prefixed field) | Converts a field declaration (e.g., “private Hashtable _MyTable;”) into code that constructs an instance of that identifier (e.g., “_MyTable = new Hashtable();”) when pasted on an empty line inside a method or property. |
Declaration | Converts a statement that constructs a new identifier into a declaration. |
Event Trigger | Creates an event trigger for an event declaration. |
Expression | Converts an assignment to an expression when pasted inside parens or following an assignment statement. |
Identifier Dot | Invokes Intellisense when pasting identifiers followed by a “.” inside code blocks. |
if block | Converts an if-statement with an expression to the extracted expression when pasted inside parens. |
Is expression | Converts a typecast to an “is” expression. Note that this expansion is disabled by default. |
Method (interface) | Creates a new method when a method declaration from an interface is pasted on an empty line inside a class or struct. |
Property | Creates a property from a field declaration. |
Property (from interface) | Creates a new property when a property declaration from an interface is pasted on an empty line inside a class or struct. |
Property (interface get) | Creates a new property when a property declaration from an interface is pasted on an empty line inside a class or struct. |
Property (interface set) | Creates a new property when a property declaration from an interface is pasted on an empty line inside a class or struct. |
Property (prefixed field) | Creates a property from a declaration for a prefixed field (e.g., “_MyField”, or “m_MyField”). |
Property (prefixed readonly field) | Creates a property from a declaration for a prefixed readonly field (e.g., “_MyField”, or “m_MyField”). |
Typecast + New Var | Creates a new local variable of the type tested in the “is” expression, and initializes it to the identifier typecast as that type. Valid on empty lines in code blocks. |
Void Method | Creates a new method declaration when a method call is pasted on an empty line outside a method. |
WPF Color Field from HTML | Converts an HTML color string (e.g., “#FF0000”) to a new color instance (e.g., “Color.FromRgb(0xFF, 0x00, 0x00)”). |
WPF Color from HTML | Converts an HTML color string (e.g., “#FF0000”) to a new color instance (e.g., “Color.FromRgb(0xFF, 0x00, 0x00)”). |
WPF Color from HTML (alpha=FF) | Converts an HTML color string (e.g., “#FFAA0000”) to a new color instance (e.g., “Color.FromRgb(0xAA, 0x00, 0x00)”). |
WPF Color from HTML (with alpha) | Converts an HTML alpha-blended color string (e.g., “#80AA0000”) to a new color instance (e.g., “Color.FromArgb(0x80, 0xAA, 0x00, 0x00)”). |