Special character in label fragment

I am using VS2010, I want to create a snippet to do the following:

When I click {

or (

, then click the snippet tab )

or }

. I created fragments, but when I write {

or (

that are listed as fragment shortcuts, they don't work.

Please, help

+3


source to share


3 answers


You just cannot use these symbols for the snippet shortcut, refer to this MSDN article: Code Snippets (C #)

The yellow note at the end of the article reads as follows:



For C # code snippets , the characters that are valid to specify a field are : alphanumeric characters, number sign (#), tilde character (~), underscore character (_), and en dash character (-).

+1


source


I'll answer a little on the left margin here.

With parentheses, the {}

reason C # doesn't have a snippet is for formatting. You will notice that as you write your code, as you type a character, the }

editor will correctly set your tabs for the code you just typed. For this reason, it should be the last thing you write in your code.

Secondly, you will notice that you are using a snippet, you must enter:



  • Fragment name
  • Argument tab
  • Type argument
  • Hit Enter.

For a 1-character chunk that results in one character, you changed only 2 keystrokes to at least three ( {

tab

enter

). The Ergo C # team probably didn't think to support this as the snippet was a good idea.

+2


source


These features are supported by "Power Power Tools", how can you live without these extensions in VS 2010.

Get all the pros from here:

http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef/

0


source







All Articles