In Mathematica editor (i.e. notebook), one of the hardest things I always found is when I want to edit some long expression, and go and remove the left end "[" of some expression then before I get the chance to remove the right "]", the code in the cell will get all messed up, since it is no longer balanced, making it really hard to go chase the, now hanging, right end "]" since it is no longer in its original place!
Here is a simple example, suppose we have this
Text[Row[{PaddedForm[currentTime, {6, 3}, NumberSigns -> {"", ""}, NumberPadding -> {"0", "0"}]}]]
now say I wanted to remove the outside Text[] call. So I delete "Text[" and before I get a chance to delete the other side "]", the notebook will now juggle things all over the place, making it hard to find the right "]". For long cell (which is the case for demonestrations work), the code can shift by large amount, and the right "]" can go out of view as well, has to scroll down and up looking for it.
Is there a way to set it, via an option or such, so that when I delete the left "[", Mathematica will automatically delete the matching right "]"? This applies for "(" and ")" as well.
This is really a big problem with the use of the notebook editor for me. Can't tell you how much time I spend just looking the hanging "]".
thanks --Nasser
I shall think about an automatic method, but I currently handle this with:
place the cursor on the first token inside the function you want to delete (in this case Row)
press Ctrl+. until everything inside is selected (twice, in this case)
Copy
press Ctrl+. once to include the function to delete in the selection
Paste
It is really quite fast once you do it a few times.
Andrew Moylan suggests this mouse variation:
Here is the variant I use for this common operation:
- Triple-click "Row", Ctrl+C, Triple-click "Text", Ctrl+V, done
I just registered here and I do not have MMA with me now, so this is just an outline of the proposed solution. This is my first answer here, so bear with me please. By the way...nice to see many mathgroupers here too. :-)
Nasser's question/problem is very common. I personally use the same technique described by Andrew. It is not difficult however solve this problem more elegantly with a button.
Create a small button palette with an action button. It would work like this:
That's it. Couple of lines of code.
Since you are at it, you might add a few more buttons to the palette. For example:
So you end up creating your own programming palette.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With