Keyword expansion is a cool feature that automagically plants metadata from an external source in a file--typically between two pre-defined characters or strings--when some event occurs. In SourceSafe, there are twelve standard keywords to which various types of metadata are appended when a file in which they reside is checked in[1].

The online documentation provides a pretty good overview of SourceSafe keyword expansion and some interesting tips and tricks to help you maximize the utility of the feature. It also explains how to enable keyword expansion in VSS. Please note that there is a minor documentation bug in this topic.  The code that appears below "If no keyword comments are specified, the following comments are assumed:" should begin with "[Keyword Comments]". More details in the FAQs below.

IMO, the most useful Visual SourceSafe keyword is $history: $. In conjunction with SourceSafe's Shadow Folder feature, the $history:  $ keyword is really nifty because it allows you to know when the file was last edited and by whom even when you're not accessing it from the database. $history: $ tells SourceSafe to add something like the following to a file when you check it in:

'$History: Form1.vb $
'*****************  Version 24  *****************
'User: Guest        Date: 10/13/03   Time: 12:49p
'Updated in

FAQs and Gotchas:
Q: How do you turn on VSS keyword expansion?
A: See how to enable keyword expansion in VSS.

Q: I enabled keyword expansion but it is still not working. Why?
A: Before using this feature, you must close and all database clients that are connected to the database.
Keywords are case-sensitive, so confirm that they are properly capitalized.
Keyword expansion is disabled by default. Use VSS Admin to make sure that the feature is enabled for files of the type to which you have added keywords (eg, "*.cs").

Q: How can I automatically add comments to keyword expanded text in my source files (*.vb, *.cs, etc)?
A: Insert the following into either your personal Ss.INI file or into the
database-wide Srcsafe.INI:
[Keyword Comments]
*.cs = "//"
*.vb = "'"

[1]Q: Can I create custom VSS keywords, such as $assembly_version: $ ?
A: No. But that would be a JAW DROPPING extensibility feature, wouldn't it?

Gotcha #1: Keyword Expansion can adversely affect performance.
Gotcha #2: Don't enable keyword expansion for binary files.  Just don't.

Additional Resources:

Ce message est fourni en l état, sans garantie d aucune sorte, et ne vous confère aucun droit. Vous assumez tous les risques liés à son utilisation.This posting is provided "AS IS" with no warranties, and confers no rights.