Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This counts as something of a basic question, but one for which I cannot find an answer. I checked the documentation, I checked google, I searched it here, I read a bunch of different things, but nobody seems to have an answer.

Basically, I'm very lazy, and I rarely feel like dealing with wrapping things in brackets if it can be avoided. Things like @ and // are very useful, but there are times when things just must be put in suitable brackets, which can get annoying when working around already written code. If only one could highlight the text and press a keyboard command and suddenly have that text wrapped in brackets...

But wait! In Basic Math Assistant there is a button that does exactly this! It's just quite cumbersome to use given that you need to have that assistant open and click on it, you might as well just do it by hand. Is there any way to get something like this to be done via a keyboard command or something similar?

share|improve this question
2  
As a start, here's some code to do it. Then you need to assign it to a shortcut. I haven't tried to get this working myself, but it's a good starting point. –  Szabolcs Oct 17 '13 at 0:39

1 Answer 1

Here is the answer given by Rolf Mertig that includes many additional shortcuts.

One of them Ctrl+T, evaluates whatever is stored in joker.m file (invoked by Ctrl+R).

There are already two examples, coincidentally the second one is exactly what you need!

Ok, so briefly:

  • Get["http://www.mertig.com/shortcuts.m"]
  • reset Mathematica
  • use Ctrl+R to open joker.m file
  • uncomment the last commented part of script
  • save,Ctrl+S, and close file.

Now, whenever you use Ctrl+T it will wrap selected part of code in []. You can modify joker.m to adjust it for your needs ofc.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.