Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Keyboard shortcuts

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
Mike ONeill Posted - Jan 19 2015 : 02:06:07 AM
Is it possible to do "Surround With" with keyboard shortcuts I can see a few in the keyboard config , I want a quick way of surrounding with try--catch

Mike
12   L A T E S T    R E P L I E S    (Newest First)
Mike ONeill Posted - Jan 25 2015 : 05:48:32 AM
Thanks Sean , That's perfect it was what I was asking for originally I just didn't realise it was there.

I see that I can add further $selected$ snippets and they show on the list.

Another (Slightly) hidden gem

Ta

Mike
sean Posted - Jan 24 2015 : 1:10:39 PM
VAssistX.VaSnippetInsert (VAssistX | Insert VA Snippet) can be bound to your own keybinding. The contents of the menu that appears when the command is invoked is dynamic in that Surround With snippets are listed if there is a selection; if there is no selection, then the surround with snippets are listed in a sub-menu. However, it is not context sensitive at this time (#region will appear regardless of caret scope/position).

If you assign mnemonics to snippet titles, then you can invoke using the letter you assign in the title. For example, in the "#if 0" snippet, I added & to the 0 -- so after the menu appears, pressing 0 invokes the #if 0 snippet.

Adding your own binding to VAssistX.VaSnippetInsert will save you the press of a letter vs using the VAssistX menu (your binding,0 vs alt+x,w,0).
Mike ONeill Posted - Jan 24 2015 : 10:30:58 AM
Sorry I meant , highlight the text you want to surround and then hit Shift Alt S

Mike
Mike ONeill Posted - Jan 24 2015 : 10:30:04 AM
How about a generic Keyboard shortcut (say Shift Alt S , that brings up a menu of available "Surrounds", presumable context sensitive (eg #region not in the middle of a method)

The menu could show either an index # to select by keyboard or a shortcut eg "tc" for try catch etc

Maybe a bit of a pinch from R# but ...

Mike
Dusan Posted - Jan 24 2015 : 03:21:54 AM
quote:
Originally posted by feline

Number 3 sounds the most useful at first, but personally I often trigger a lot of "small" snippets, t for True, without thinking about it, so the last used snippet is not always going to be snippet I expect it to be.



Oops, I did not realize that.

Another possible solution for this issue could be to make an option in VA Snippet Editor to permanently or temporarily assign any snippet to # snippet. In case of permanent assignment, change would be written to .TPL file, in case of temporary assignment only information valid for current IDE session would be set by VA Snippet Editor which will tell VA to insert different snippet when # snippet is used. VA Snippet Editor would also have an option to restore # snippet manually.
feline Posted - Jan 23 2015 : 5:34:36 PM
Personally I am wary of number 1. Technically I like the idea, but especially in the context of shared snippets, it could cause problems, since I am not sure people would ever expect this to happen.

Number 3 sounds the most useful at first, but personally I often trigger a lot of "small" snippets, t for True, without thinking about it, so the last used snippet is not always going to be snippet I expect it to be.

So I find myself preferring number 2, so long as there are a few numbered accelerators. It is not quite so elegant, but probably easier to work with on a day to day basis, and its useful when you are working with a few common snippets. For example I have a "start block" and "end block" snippet pair that I use a lot. I enter them separately since working out the block in advance, and selecting it, proved to be more work than just triggering them separately.

Just my perspective though, I am certainly interested in other perspectives on this.
Dusan Posted - Jan 23 2015 : 1:07:28 PM
We have discussed the issue internally and there raised three new potential features:

1) Allow a new shortcut attribute on snippets such the snippet is invoked only when there is a selection that includes a linebreak. So for example, a press of 't' normally inserts a t or overwrites a sub-line selection with t but if there is a multiline selection, then the snippet associated with 't' is invoked (for example, try/catch)

2) (In addition to 1) List a few most-recently-used snippets at the top of the snippet menu, with numbered accelerators. (Maybe just the last snippet.)

3) Provide new VA command (VaSnippetInsertRecent) that would insert last inserted snippet within current VS session. For example, you use VaSnippetInsert, and choose one snippet to apply. If you want to apply same snippet again, you invoke VaSnippetInsertRecent. If you would want to insert different snippet (or start a new row), you use VaSnippetInsert again which also defines new snippet for next calls of VaSnippetInsertRecent. If there would not be any snippet inserted within current VS session, menu with snippets still will be opened as if you use VaSnippetInsert.

Which of these options would you want to see in VA?
sean Posted - Jan 23 2015 : 12:39:27 PM
An alternative is to modify your try/catch to use $clipboard$ instead of $selection$ -- it will no longer be a Surround With snippet.

To invoke your new try/catch, select your code as you would with a surround with snippet.
Cut.
Invoke the snippet via its shortcut (typing try).

The cut text gets inserted with the snippet.

If you want to keep the Surround With version of the snippet, you can copy/paste it in the snippet editor and modify the second version.


A different alternative as noted by Jeff:
edit the try/catch snippet title by adding '&' before 'y' in the word try.
make your selection.
invoke surround with try: alt+x,w,y
Jeff Posted - Jan 23 2015 : 12:32:45 PM
You can read more about keyboard access to surround-with snippets in the documentation for Visual Assist. In short, keyboard access opens a menu and accelerators make the final selection.

http://docs.wholetomato.com/default.asp?W257
feline Posted - Jan 22 2015 : 1:38:21 PM
Did you try editing the "#ifdef (VA)" snippet? This would allow you to do this, so long as you don't mind trading the #ifdef block for the try / catch block.

You can also map a keyboard shortcut to the command VAssistX.VaSnippetInsert, personally I have mapped Ctrl-#, which makes it quick and simple to select one of the VA snippets you have that use $selected$.

We have to be careful "eating" key presses, since when people select code and start typing, they expect the typing to just work.
Mike ONeill Posted - Jan 22 2015 : 12:11:02 AM
Thanks , I found a way around it , but maybe one to add to that "long" list of nice goodies

Mike
accord Posted - Jan 20 2015 : 3:30:57 PM
No, unfortunately you cannot do that.
However, the snippet "#ifdef (VA X)" can be triggered by the # key (Shift+3). So if you overwrite it, you will be able to trigger it easily.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000