SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => Did you know? => Topic started by: Lisa on January 29, 2008, 04:43:50 PM

Title: How to Beat Down an "else" Statement in Three Keystrokes
Post by: Lisa on January 29, 2008, 04:43:50 PM
Suppose you want to get from something like this:

Code: [Select]
       if ( cond ) {
          doSomething();
       } else {
          goSomewhere();
          doSomethingElse();
          comeBack();
          takeANap();
       }

To this:

Code: [Select]
       if ( cond ) {
          doSomething();
       }
       goSomewhere();
       doSomethingElse();
       comeBack();
       takeANap();

1. First, put your cursor on "else" and press Ctrl+Shift+Right to select it.
2. Press Enter.
3. Press Ctrl+Delete, and select Unsurround the code block.

Though Unsurround does not normally apply to "else" blocks, this example shows how you can manipulate your code to make a feature work for you in order to save time.