In a recent post, I announced a plugin that would bring a few features from nostalgic Emacs days to the modern world of Visual Studio 2003 and CodeRush. I received some feedback on that first version and now the Updated, Fixed and Obviously Much Better New Version™ is available. To start with, here’s the download link again, for the current version: CR_ElectricEditing-current.zip

If you need instructions to get the plugin installed, review my first post on the topic, please. Now, what can that fantastic plugin do? I’ll show you some screenshots and provide some explanations with them.

Deletion

One part of the functionality is related to deleting stuff. Not only stuff, but quite specific stuff, namely whitespace. Have you ever noticed how cumbersome it is to get back to the point you where working at after accidentally hitting Return? Electric Editing provides the Electric Backspace function (Hungry Backspace is what is was called in Emacs, for good reasons) that deletes all the whitespace left of the caret in one go. The standard options for that look like this:

electricbackspace.png

With the exception of deleting recent electric insertions (which wouldn’t make much sense), the same options are available for the Delete key:

electricdelete.png

In addition to the pure functionality, a hinting option has been introduced that allows you to anticipate exactly what will be deleted if you use the Backspace or Delete at any time. The hint lines will always reflect the exact options you have set for the above features. You can switch hinting on and off and configure its color:

whitespacehints.png

Here’s a screenshot of the hints in action, with the color set to blazing red to make them clearly visible.

whitespacehints2.png

Automatic linefeeds

The remaining functionality is all about automatically adding linefeeds when certain characters are inserted in the code. There are several options for this, which should really be quite self-explanatory. You can have linefeeds inserted before and after opening and closing braces, as well as after the semicolon. By default, the braces don’t get any linefeeds added if the caret is within parentheses at that moment, because it’s assumed that you want to create an inline array initialisation, like here:

MethodInfo mi = typeof(MyClass).GetMethod("DoSomething");
mi.Invoke(anObject, new object[] { one, another });

If you want to insert linefeeds before braces, you have the option to do that only if the caret isn’t already on an empty line.

autolinefeeds.png

Important: The semicolon also jumps to the end of the line before inserting itself. Because of this, there’s a conflict with CodeRush’s own smart semicolon feature, which you need to switch off to get the Electric Editing semicolon to work correctly. To do this, enter the CodeRush options dialog via the menu entry DevExpress/Options… Then make sure that the Level (the combo box in the lower left corner of the dialog) is set to Advanced or even Expert. Navigate to the page Editor/Auto Complete/Intellassist/Parens & Brackets. On this page, deactivate the two options “Smart semi-colon”, one in each of the settings groups. I hope the following screenshot makes this clearer:

crsmartsemicolonoff.png

That’s it then. Have fun and don’t forget to give feedback if there’s anything you like, or don’t!