Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 How to create a cheat sheet from VA Snippets?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Hvergelmir
Junior Member

11 Posts

Posted - Aug 21 2018 :  10:44:46 AM  Show Profile  Reply with Quote
Hi,

is there a way to create a cheat sheet from the VA Snippets? Naturally I am mostly interested in those that have a shorthand version, although a list of the others would also be nice for the learning experience.

Thanks and best regards.

Oh and if this doesn't exist, I'd like to propose this as a feature suggestion.

Edited by - Hvergelmir on Aug 21 2018 10:45:57 AM

feline
Whole Tomato Software

United Kingdom
18754 Posts

Posted - Aug 21 2018 :  1:58:30 PM  Show Profile  Reply with Quote
Assuming you are using VS2010 or above you will have the new Snippet Editor. Use the "Type" drop down field to list "All by Shortcut", which will list all of the snippets with a shortcut on your system, showing the shortcut first in bold, to make it easier to pick out.

You can also set this to show you all "Surround With" snippets, which are snippets that are designed to surround a selected piece of code with the new snippet.

You can easily make up a list of the ones that interest you from here. We have tried to make the default shortcuts "obvious", so you will find them as you type. For example "if", "try" and "class".

zen is the art of being at one with the two'ness
Go to Top of Page

Hvergelmir
Junior Member

11 Posts

Posted - Aug 21 2018 :  3:13:39 PM  Show Profile  Reply with Quote
Alright, this is indeed a good start. Yes, I do have several VS versions ranging from VS2005 to VS2017, but was asking for the latter.

Thanks for your swift response.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18754 Posts

Posted - Aug 21 2018 :  4:19:08 PM  Show Profile  Reply with Quote
The snippets and their shortcuts are common across all versions of Visual Studio on a single machine. They are just stored once, and loaded by each IDE, so the list you get from the newer IDE's snippet editor will be equally valid in the older IDE's.

If you want to extract some of this information to format up as a document to print out for easy reference, you can multiple select in the column list of snippets in the new snippet editor. Hold down Alt and left mouse click as normal to do this. If you now use Ctrl-C XML format versions of these snippets are then copied to your clipboard, which you can use to easily extract the shortcut and description and format up this information to suit your needs.

zen is the art of being at one with the two'ness
Go to Top of Page

Jeff
Whole Tomato Software

USA
260 Posts

Posted - Aug 21 2018 :  6:56:43 PM  Show Profile  Reply with Quote
If you are familiar with *nix, paste the copied XML into snippets.txt. Then, use the following shell script to create a cheat sheet. I tested this script in the Unbuntu distro of WSL.

#!/bin/bash
export LC_ALL=C		# include leading characters in sort
cat snippets.txt | \
  sed -e 's/\r//g' | \
  grep -v '^$' | \
  paste -s -d'|' | \
  sed -e 's/<\/VA_Snippet>|<VA_Snippet>/\n/g' -e "s/$(printf '\t')//g" | \
  grep -v '<Shortcut />'  | \
  sed -e 's/.*<Shortcut>\(.*\)<\/Shortcut>.*<Code>\(.*\)<\/Code>.*/\1\t\t\2/' | \
  sort

Send email to [email protected] and mention topic 15305 if you want the commands in a file. They were not easy to paste into our forums editor; they might be wrong.

Edited by - Jeff on Aug 21 2018 7:04:50 PM
Go to Top of Page

Hvergelmir
Junior Member

11 Posts

Posted - Aug 22 2018 :  06:14:32 AM  Show Profile  Reply with Quote
quote:
Originally posted by Jeff

If you are familiar with *nix, paste the copied XML into snippets.txt. Then, use the following shell script to create a cheat sheet. I tested this script in the Unbuntu distro of WSL.

Thanks Jeff. Yeah, I am working on the terminal on a number of Unixes, most notably Linux, all the time. You may want to give the xmlstarlet and xgrep packages/tools a try, though, for this kind of task from the command line.

Anyway, I'll probably rather create a Python script to do the job and post it here. Perhaps it's useful to others as well.

One more question, though, in that case. Can I get the entirety of a set of VA Snippets into XML format easily or is it always a one-by-one task?
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18754 Posts

Posted - Aug 22 2018 :  08:28:08 AM  Show Profile  Reply with Quote
If you want, place keyboard focus into the column control, then use Ctrl-A to select all currently visible snippets, and then Ctrl-C to copy all of the snippets in one go to the clipboard.

If you want a specific set of snippets, try setting the "Type" drop down field to "Search...", which will allow you to search for the block of snippets you want.

You are more than welcome to post a script here for converting the XML into something more helpful. Just don't be surprised if someone then asks you to support it is all

zen is the art of being at one with the two'ness
Go to Top of Page

Hvergelmir
Junior Member

11 Posts

Posted - Aug 23 2018 :  4:41:32 PM  Show Profile  Reply with Quote
It'll be open source, so it can be "forked" if ever needed :)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000