Shortcut for wraping a selected text with formating on/off?

I need to prevent some code for being formatted. Sometimes there are lot of lines and typing manually


my piece of code


takes a lot of time.

What I need is to select some code and wrap the code with above statements.

Is there a way to achieve that?

Comment actions Permalink

Hi there,

Live Template of surround kind?

Create template first, select text, apply.


Comment actions Permalink

It's perfect. I wasn't aware about surrounding templates. However I've got problem with assigning a keyboard shortcut to macro to get it works faster.

I recorded a two steps macro and assigned it to ctrl + shift + O

step 1. action surround with live template;

step 2. type "r"(it's from live template's abbreviation)

When I select target text and press ctrl + shif + O it shows me my livetemplates list

However when run macro manually from Edit -> Macros

It works great:

Do you have got any idea why it doesn't work with keyboard shortcut?



Comment actions Permalink

IDE version?

How do you press the shortcut? You need to press and release all keys at the same time. If you keep Ctrl and/or Shift key pressed while O is already released then it will not finish selecting template...

Also -- what was the macro sequence? I mean -- how did you select the needed template? As I understand you pressed the underlined letter r (so only 1 press needed). I suggest to use full abbreviation instead (as I understand it's "re" on your screenshot; type the actual abbreviation and confirm with Enter). Create couple of surround templates (for the same context) to see how it works.

Comment actions Permalink

Basically you were right about that: "If you keep Ctrl and/or Shift key pressed while O is already released then it will not finish selecting template..." You have to release all keys combination in very same time, which is nearly impossible at first time. However thank you very much for your help.

Regards macro they should have add more iddle time to wait for releasing all keys, because in this case it's impossible to use such combination in normal work.


Comment actions Permalink

I already wrote there. I left my comment here just for the record.

Comment actions Permalink

I see. Sorry for confusion.


Please sign in to leave a comment.