Tue 28 Apr 2009
How to Beat Down an “else” Statement in Three Keystrokes
Posted by Jeffrey under Productivity
[2] Comments
Suppose you want to get from something like this:
if ( cond ) {
doSomething();
} else {
goSomewhere();
doSomethingElse();
comeBack();
takeANap();
}
To this:
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.
April 28th, 2009 at 9:56 pm
hi,can navigate icons do the same thing like source insight? now visual studio also have the same operation.why doesn’t slickedit have?
we just want to navigate the cursor position, not the bookmark or others. or can i config it?
thanks.
June 4th, 2009 at 12:53 pm
This idea is a fine one that is often overlooked. But lets not forget that this is only a valid situation if the code in “doSomething()” isn’t mutually exclusive to the code after the “if{}” block because in the “fixed” version that code gets to run no matter what happens in “doSomething()”.