By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,118 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Best ways to source controlling "Code Snippets"

P: n/a
I am interested in learning how to use the VS 2005 code snippets.
However, I wish to know what are the best ways to source control the
code snippets?

Are there any source safe/subversion add-ons for this purpose?

If not, any urls which demonstrates code snippets management?
I apologize for the cross-posting. This is relative obscure question,
and wish to get as much exposure as possible.

great thanks
Frank

Mar 23 '07 #1
Share this Question
Share on Google+
13 Replies


P: n/a
http://msdn2.microsoft.com/en-us/vbasic/ms789085.aspx

Code snippets are the best thing since shirt pockets.

Robin S.
-----------------------------
<fr*****@gmail.comwrote in message
news:11**********************@y80g2000hsf.googlegr oups.com...
>I am interested in learning how to use the VS 2005 code snippets.
However, I wish to know what are the best ways to source control the
code snippets?

Are there any source safe/subversion add-ons for this purpose?

If not, any urls which demonstrates code snippets management?
I apologize for the cross-posting. This is relative obscure question,
and wish to get as much exposure as possible.

great thanks
Frank

Mar 23 '07 #2

P: n/a
That may be Robin but Confucius said "man with hole in pocket feels cocky
all day."

I'm using an application called Snippy that works fairly well for C#.

<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:ut******************************@comcast.com. ..
http://msdn2.microsoft.com/en-us/vbasic/ms789085.aspx

Code snippets are the best thing since shirt pockets.

Robin S.
-----------------------------
<fr*****@gmail.comwrote in message
news:11**********************@y80g2000hsf.googlegr oups.com...
>>I am interested in learning how to use the VS 2005 code snippets.
However, I wish to know what are the best ways to source control the
code snippets?

Are there any source safe/subversion add-ons for this purpose?

If not, any urls which demonstrates code snippets management?
I apologize for the cross-posting. This is relative obscure question,
and wish to get as much exposure as possible.

great thanks
Frank


Mar 23 '07 #3

P: n/a
LOL. Thanks, I needed that on a Friday afternoon.

And what's the deal with C# not having nearly as many code snippets as VB?
Did someone at MS fall down on the job?

And while I'm at it, in VB you can type ? and tab and it will bring up the
code snippets. Is there a shortcut for C#?

Thanks,
Robin S.
------------------------------------------
"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.comwro te in message
news:ey**************@TK2MSFTNGP05.phx.gbl...
That may be Robin but Confucius said "man with hole in pocket feels cocky
all day."

I'm using an application called Snippy that works fairly well for C#.

<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:ut******************************@comcast.com. ..
>http://msdn2.microsoft.com/en-us/vbasic/ms789085.aspx

Code snippets are the best thing since shirt pockets.

Robin S.
-----------------------------
<fr*****@gmail.comwrote in message
news:11**********************@y80g2000hsf.googleg roups.com...
>>>I am interested in learning how to use the VS 2005 code snippets.
However, I wish to know what are the best ways to source control the
code snippets?

Are there any source safe/subversion add-ons for this purpose?

If not, any urls which demonstrates code snippets management?
I apologize for the cross-posting. This is relative obscure question,
and wish to get as much exposure as possible.

great thanks
Frank



Mar 23 '07 #4

P: n/a
Snippy is a VS2005 add-in and called using Ctrl-K, Ctrl-B

Here's more from "Help on Snippy"...

How to get started:

This code snippet editor will help you write snippets that conform to the
following schema:
http://schemas.microsoft.com/VisualS...05/CodeSnippet.

The following xml is a simple example of what this will produce:
<CodeSnippets
xmlns="http://schemas.microsoft.com//VisualStudio//2005//CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>
My Snippet
</Title>
</Header>
<Snippet>
<Code Language="CSharp">
<![CDATA[MessageBox.Show("Hello World");]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>

The following fields are required for a snippet to work inside of Visual
Studio: Title, SnippetTypes, Code, Language.

Title - This is the name of the snippet that will be visible in the
code snippet picker and the code snippet manager.
Shortcut - If you want to invoke your snippet through the keyboard, you
can assign it a shortcut. Pressing the shortcut and hitting "Tab" will
insert your new snippet in the editor.
SnippetTypes - Expansion is for a snippet that inserts text. SurroundsWith
is for snippets that will surround a block of text such as a for loop
Language - This is required to know which type of language the snippet
you are creating will work for. The currently supported lanugages are VB,
C#, J# and XML
Code - The actual code that will be spit into the editor is required
here. In the above example, this is the text that is wrapped in the CDATA
section. You do not need to include the CDATA block
Adding a Literal or Object:
The Literal element is used to identify a replacement for a piece of code
that is entirely contained within the snippet, but will likely be customized
after it is inserted into the code. For example, literal strings, numeric
values, and some variable names should be declared as literals.
The Object element is used to identify an item that is required by the
code snippet but is likely to be defined outside of the snippet itself. For
example, Windows Forms controls, ASP.NET controls, object instances, and
type instances should be declared as objects. Object declarations require
that a type be specified.
Use the Add button on the literals/objects section to add a new literal.
ID and default value are the only required fields.
Now that you have created literals and objects, you need a way to use them
in the code that will be inserted by the code snippet. You reference the
literals and objects you have declared in the Declarations element by
placing $ symbols at the beginning and end of the value in the literal or
object's ID elementTo reference a literal or object in a Code element, place
$ symbols at the beginning and end of the literal or object's ID element
value. For example, if a literal has an ID element that contains the value
MyID, you would reference that literal in the Code text box with $MyID$.

After creating your snippet, you need to save it to a location that Visual
Studio will be able to access it from. In Visual Studio, go to the Tools
menu and choose Code Snippet Manager. Here you can select the language that
the snippets you are creating refer to. From there you will be able to see
the directories where you can place the snippet. Copy one of these
locations and save your snippet there. Visual Stuido wil then automatically
pick up your newly created snippet.

--
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:pN******************************@comcast.com. ..
LOL. Thanks, I needed that on a Friday afternoon.

And what's the deal with C# not having nearly as many code snippets as VB?
Did someone at MS fall down on the job?

And while I'm at it, in VB you can type ? and tab and it will bring up the
code snippets. Is there a shortcut for C#?

Thanks,
Robin S.
------------------------------------------
"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.comwro te in message
news:ey**************@TK2MSFTNGP05.phx.gbl...
>That may be Robin but Confucius said "man with hole in pocket feels cocky
all day."

I'm using an application called Snippy that works fairly well for C#.

<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:ut******************************@comcast.com ...
>>http://msdn2.microsoft.com/en-us/vbasic/ms789085.aspx

Code snippets are the best thing since shirt pockets.

Robin S.
-----------------------------
<fr*****@gmail.comwrote in message
news:11**********************@y80g2000hsf.google groups.com...
I am interested in learning how to use the VS 2005 code snippets.
However, I wish to know what are the best ways to source control the
code snippets?

Are there any source safe/subversion add-ons for this purpose?

If not, any urls which demonstrates code snippets management?
I apologize for the cross-posting. This is relative obscure question,
and wish to get as much exposure as possible.

great thanks
Frank



Mar 23 '07 #5

P: n/a
I tried out your link to the code snippet editor, and get a "page cannot be
found". Try out the link I gave; it's probaby the same thing you're talking
about.

http://msdn2.microsoft.com/en-us/vbasic/ms789085.aspx

The Ctrl-K Ctrl-B thing is what *I* was looking for! Thanks!

Robin S.
-------------
"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.comwro te in message
news:Oe**************@TK2MSFTNGP05.phx.gbl...
Snippy is a VS2005 add-in and called using Ctrl-K, Ctrl-B

Here's more from "Help on Snippy"...

How to get started:

This code snippet editor will help you write snippets that conform to the
following schema:
http://schemas.microsoft.com/VisualS...05/CodeSnippet.

The following xml is a simple example of what this will produce:
<CodeSnippets
xmlns="http://schemas.microsoft.com//VisualStudio//2005//CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>
My Snippet
</Title>
</Header>
<Snippet>
<Code Language="CSharp">
<![CDATA[MessageBox.Show("Hello World");]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>

The following fields are required for a snippet to work inside of Visual
Studio: Title, SnippetTypes, Code, Language.

Title - This is the name of the snippet that will be visible in
the code snippet picker and the code snippet manager.
Shortcut - If you want to invoke your snippet through the keyboard,
you can assign it a shortcut. Pressing the shortcut and hitting "Tab"
will insert your new snippet in the editor.
SnippetTypes - Expansion is for a snippet that inserts text.
SurroundsWith is for snippets that will surround a block of text such as
a for loop
Language - This is required to know which type of language the
snippet you are creating will work for. The currently supported
lanugages are VB, C#, J# and XML
Code - The actual code that will be spit into the editor is
required here. In the above example, this is the text that is wrapped in
the CDATA section. You do not need to include the CDATA block
Adding a Literal or Object:
The Literal element is used to identify a replacement for a piece of
code that is entirely contained within the snippet, but will likely be
customized after it is inserted into the code. For example, literal
strings, numeric values, and some variable names should be declared as
literals.
The Object element is used to identify an item that is required by the
code snippet but is likely to be defined outside of the snippet itself.
For example, Windows Forms controls, ASP.NET controls, object instances,
and type instances should be declared as objects. Object declarations
require that a type be specified.
Use the Add button on the literals/objects section to add a new literal.
ID and default value are the only required fields.
Now that you have created literals and objects, you need a way to use
them in the code that will be inserted by the code snippet. You reference
the literals and objects you have declared in the Declarations element by
placing $ symbols at the beginning and end of the value in the literal or
object's ID elementTo reference a literal or object in a Code element,
place $ symbols at the beginning and end of the literal or object's ID
element value. For example, if a literal has an ID element that contains
the value MyID, you would reference that literal in the Code text box
with $MyID$.

After creating your snippet, you need to save it to a location that
Visual Studio will be able to access it from. In Visual Studio, go to
the Tools menu and choose Code Snippet Manager. Here you can select the
language that the snippets you are creating refer to. From there you
will be able to see the directories where you can place the snippet.
Copy one of these locations and save your snippet there. Visual Stuido
wil then automatically pick up your newly created snippet.

--
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:pN******************************@comcast.com. ..
>LOL. Thanks, I needed that on a Friday afternoon.

And what's the deal with C# not having nearly as many code snippets as
VB? Did someone at MS fall down on the job?

And while I'm at it, in VB you can type ? and tab and it will bring up
the code snippets. Is there a shortcut for C#?

Thanks,
Robin S.
------------------------------------------
"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.comwro te in
message news:ey**************@TK2MSFTNGP05.phx.gbl...
>>That may be Robin but Confucius said "man with hole in pocket feels
cocky all day."

I'm using an application called Snippy that works fairly well for C#.

<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:ut******************************@comcast.co m...
http://msdn2.microsoft.com/en-us/vbasic/ms789085.aspx

Code snippets are the best thing since shirt pockets.

Robin S.
-----------------------------
<fr*****@gmail.comwrote in message
news:11**********************@y80g2000hsf.googl egroups.com...
>I am interested in learning how to use the VS 2005 code snippets.
>
>
However, I wish to know what are the best ways to source control the
code snippets?
>
Are there any source safe/subversion add-ons for this purpose?
>
If not, any urls which demonstrates code snippets management?
>
>
I apologize for the cross-posting. This is relative obscure question,
and wish to get as much exposure as possible.
>
great thanks
Frank
>




Mar 23 '07 #6

P: n/a
On Mar 23, 10:43 pm, "RobinS" <Rob...@NoSpam.yah.nonewrote:
LOL. Thanks, I needed that on a Friday afternoon.

And what's the deal with C# not having nearly as many code snippets as VB?
Did someone at MS fall down on the job?
http://msdn2.microsoft.com/en-us/vstudio/aa718338.aspx

Mar 24 '07 #7

P: n/a

"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@l75g2000hse.googlegr oups.com...
On Mar 23, 10:43 pm, "RobinS" <Rob...@NoSpam.yah.nonewrote:
>LOL. Thanks, I needed that on a Friday afternoon.

And what's the deal with C# not having nearly as many code snippets as
VB?
Did someone at MS fall down on the job?

http://msdn2.microsoft.com/en-us/vstudio/aa718338.aspx
Thank you! Awesome!!

Now, is there a way to invoke "Insert Code Snippet" without using the
context menu in the code window? In VB, you can type ? and tab and it
brings them up. Is there any such shortcut in C#?

Robin S.
Mar 24 '07 #8

P: n/a
On Mar 24, 4:35 pm, "RobinS" <Rob...@NoSpam.yah.nonewrote:
>
Thank you! Awesome!!

Now, is there a way to invoke "Insert Code Snippet" without using the
context menu in the code window? In VB, you can type ? and tab and it
brings them up. Is there any such shortcut in C#?
Ctrl+K+X

More information about Code Snippets:
http://msdn2.microsoft.com/en-us/lib...92(VS.80).aspx

Mar 24 '07 #9

P: n/a
On Mar 24, 11:47 am, "Alexey Smirnov" <alexey.smir...@gmail.com>
wrote:
On Mar 24, 4:35 pm, "RobinS" <Rob...@NoSpam.yah.nonewrote:
Thank you! Awesome!!
Now, is there a way to invoke "Insert Code Snippet" without using the
context menu in the code window? In VB, you can type ? and tab and it
brings them up. Is there any such shortcut in C#?

Ctrl+K+X

More information about Code Snippets:http://msdn2.microsoft.com/en-us/lib...92(VS.80).aspx
Hi,

Sorry to bother.

What is the best way to ensure all the developers on a team have the
same code snippets on their machines?

What is the best way to source control the code snippets?

regards
Frank

Mar 24 '07 #10

P: n/a
"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...
On Mar 24, 4:35 pm, "RobinS" <Rob...@NoSpam.yah.nonewrote:
>>
Thank you! Awesome!!

Now, is there a way to invoke "Insert Code Snippet" without using the
context menu in the code window? In VB, you can type ? and tab and it
brings them up. Is there any such shortcut in C#?

Ctrl+K+X

More information about Code Snippets:
http://msdn2.microsoft.com/en-us/lib...92(VS.80).aspx
Thanks very much!!

Robin S.
Mar 24 '07 #11

P: n/a

<fr*****@gmail.comwrote in message
news:11*********************@o5g2000hsb.googlegrou ps.com...
On Mar 24, 11:47 am, "Alexey Smirnov" <alexey.smir...@gmail.com>
wrote:
>On Mar 24, 4:35 pm, "RobinS" <Rob...@NoSpam.yah.nonewrote:
Thank you! Awesome!!
Now, is there a way to invoke "Insert Code Snippet" without using the
context menu in the code window? In VB, you can type ? and tab and it
brings them up. Is there any such shortcut in C#?

Ctrl+K+X

More information about Code
Snippets:http://msdn2.microsoft.com/en-us/lib...92(VS.80).aspx

Hi,

Sorry to bother.

What is the best way to ensure all the developers on a team have the
same code snippets on their machines?

What is the best way to source control the code snippets?

regards
Frank
I'd put them on a share, and add that library to the Code Snippet Manager.
That way, if you write your own, you can store them there and everyone can
get to them.

Robin S.
Mar 24 '07 #12

P: n/a
On Mar 24, 5:40 pm, frk....@gmail.com wrote:
On Mar 24, 11:47 am, "Alexey Smirnov" <alexey.smir...@gmail.com>
wrote:
On Mar 24, 4:35 pm, "RobinS" <Rob...@NoSpam.yah.nonewrote:
Thank you! Awesome!!
Now, is there a way to invoke "Insert Code Snippet" without using the
context menu in the code window? In VB, you can type ? and tab and it
brings them up. Is there any such shortcut in C#?
Ctrl+K+X
More information about Code Snippets:http://msdn2.microsoft.com/en-us/lib...92(VS.80).aspx

Hi,

Sorry to bother.

What is the best way to ensure all the developers on a team have the
same code snippets on their machines?

What is the best way to source control the code snippets?

regards
Frank
Use a public shared folder for common snippets

http://msdn2.microsoft.com/en-us/lib...sb(VS.80).aspx

Mar 24 '07 #13

P: n/a
On Mar 24, 4:50 pm, "Alexey Smirnov" <alexey.smir...@gmail.comwrote:
On Mar 24, 5:40 pm, frk....@gmail.com wrote:
On Mar 24, 11:47 am, "Alexey Smirnov" <alexey.smir...@gmail.com>
wrote:
On Mar 24, 4:35 pm, "RobinS" <Rob...@NoSpam.yah.nonewrote:
Thank you! Awesome!!
Now, is there a way to invoke "Insert Code Snippet" without using the
context menu in the code window? In VB, you can type ? and tab and it
brings them up. Is there any such shortcut in C#?
Ctrl+K+X
More information about Code Snippets:http://msdn2.microsoft.com/en-us/lib...92(VS.80).aspx
Hi,
Sorry to bother.
What is the best way to ensure all the developers on a team have the
same code snippets on their machines?
What is the best way to source control the code snippets?
regards
Frank

Use a public shared folder for common snippets

http://msdn2.microsoft.com/en-us/lib...sb(VS.80).aspx
many thx

Mar 24 '07 #14

This discussion thread is closed

Replies have been disabled for this discussion.