⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme.htm

📁 代码模版 codtemplate
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<h1>Code&lt;Template&gt; Addin for Visual Studio .NET</h1>
<h2>Version 1.9 - RC2&nbsp;&nbsp; <a href="#LastVersion"><font size="2">What's New?</font></a></h2>
<h2><a name="Updates"></a>Introduction</h2>
<p>Code&lt;Template&gt;.NET is an addin for Visual Studio.NET that provides a 
	mechanism for inserting commonly used text fragments into your source code. It 
	is based on the ideas presented in <a href="http://www.codeguru.com/mfc/comments/9606.shtml">
		my</a> additions to <a href="http://www.codeguru.com/devstudio_macros/code_template_taylor.shtml">
		Michael Taylor's</a> extension to <a href="http://www.codeguru.com/devstudio_macros/code_template.shtml">
		Darren Richard's</a> original CodeTmpl addin.</p>
<p>The main differences with the original CodeTmpl addin are:</p>
<ul>
	<li>
	Support for Visual Studio.NET
	<li>
	Rewritten from scratch in C#
	<li>
	Cleaner file format
	<li>
	Keyword, environment and prompted replaceable values
	<li>
		Predefined and .NET standard formatters
	</li>
</ul>
<p>The text fragments used by Code&lt;Template&gt;.NET are contained in&nbsp;files 
	called <strong>CodeTmpl.* </strong>(where * is&nbsp;a per-language 
	extension)&nbsp;which&nbsp;are located in the user's roaming profile. These 
	files&nbsp;are originally copied from sample files which&nbsp;are located same 
	directory as the addin's executable. The format of these text files is very 
	simple: named blocks contain the text fragments that will be inserted in your 
	source code. Besides the directly inserted text, these fragments can also 
	contain tags which represent replaceable keywords and prompted values. These 
	named blocks will show up as menus and submenus in Code&lt;Template&gt;.NET's 
	toolbar button. When you click on one of these menu items, the corresponding 
	text fragment will be inserted in the active window's insertion point.</p>
<h2>Configuration</h2>
<p>
	The&nbsp;template files&nbsp;are completely configurable so you can replace or 
	change the default text fragments to suit your own needs. The format of 
	the&nbsp;template files is extremely simple. Basically you paste your block of 
	code into the file and surround it with the <strong><em>open menu</em></strong> 
	(<strong>#{ </strong>) and <strong><em>close menu</em></strong> (<strong>}#</strong>) 
	tags. The open menu tag should be followed by the name that will appear on the 
	popup menu. The open menu tag can also include a Menu ID that is separated from 
	the display name by a vertical bar (<strong>|</strong>); this Menu ID is used 
	to directly insert a template into the editor by pressing <em><strong>Ctrl+Enter</strong></em>. 
	Whatever text is placed between the open and close menu tags will be copied 
	verbatim into the text editor. Menu items can be nested, creating a 
	hierarchical view of templates. You can also specify an access key by placing 
	an '<strong>&amp;</strong>' character before the character to be used as the 
	access key. For example, to specify the "F" in "File" as an access key, you 
	would specify the caption for the menu name as "&amp;File". You can use this 
	feature to provide keyboard navigation for your templates. A <i><strong>separator</strong></i>
	(<strong>##</strong>) tag can be used to separate menu items and an <strong>exclamation 
		mark</strong> (!) at the start of a line is used for single line comments.</p>
<p>Additional template files can be included by adding a line starting with "<strong>#include</strong>" 
	followed by the file name. If the file name does not have an absolute path, the 
	file will be searched for&nbsp;relative to the base template file in the user's 
	roaming profile. Include statements can only be inserted between menu and 
	submenu definitions.</p>
<p>For example:</p>
<pre>#{Hello World - &amp;Console|hwc 
#include &lt;iostream&gt; 
int main()
{
   std::cout &lt;&lt; "Hello, new world!\n";
}
#}

##########################

#{Hello World - &amp;GUI|hwg
#include &lt;WinUser.h&gt;

int PASCAL WinMain(HANDLE hInstance,
                   HANDLE hPrevInstance,
                   LPSTR lpszCommandLine,
                   int cmdShow)
{
    MessageBox(NULL, "Hello, World", "Example", MB_OK);
}
#}</pre>
<p>If your&nbsp;template file&nbsp;contained the above text then clicking the 
	CodeTmpl toolbar button would display a popup menu containing the options <i>Hello 
		World - <u>C</u>onsole</i> and <i>Hello World - <u>G</u>UI</i>, with a 
	separator between them. Selecting <i>Hello World - Console</i> would paste the 
	text shown between the '#{' and '#}' tags into your source; a speedier way to 
	insert this template would be to type <strong><em>hwc</em></strong> and then 
	press <strong><em>ctrl+&lt;space&gt;</em></strong> .
</p>
<h2>Keywords</h2>
<p>The replaceable text between the menu open and menu close tags can contain 
	replaceable keywords. These keywords are surrounded by the <i><strong>keyword open</strong></i>
	(<strong>&lt;%</strong> ) and <i><strong>keyword close</strong></i> (<strong>%&gt;</strong>) 
	tags and are case-insensitive. To insert these tags verbatim in the text (in 
	ASP templates for example) escape the <strong>percent</strong> ('<strong>%</strong>') 
	symbol&nbsp;by preceding it with a <strong>backslash</strong> ('<strong>\</strong>'). 
	The <strong>less than</strong> ('<strong>&lt;</strong>') and the <strong>greater 
		than</strong> ('<strong>&gt;</strong>') characters are escapable too.</p>
<p>Currently, the following keywords are predefined:</p>
<table id="keywords" width="100%">
	<tbody>
		<tr valign="top">
			<td width="97"><strong>SOLUTION</strong></td>
			<td>Returns the solution name</td>
		</tr>
		<tr valign="top">
			<td width="97"><strong>PROJECT</strong></td>
			<td>Returns the current project name</td>
		</tr>
		<tr valign="top">
			<td width="97"><strong>FILE</strong></td>
			<td>Returns the current file name</td>
		</tr>
		<tr valign="top">
			<td width="97"><strong>NOW</strong></td>
			<td>Returns the current date and time</td>
		</tr>
		<tr valign="top">
			<td width="97"><strong>TODAY</strong></td>
			<td>Returns the current date</td>
		</tr>
		<tr valign="top">
			<td width="97"><strong>GUID</strong></td>
			<td>
				<p>Returns a GUID</p>
			</td>
		</tr>
		<tr>
			<td width="97"><strong>TEMPLATE</strong></td>
			<td>Inserts the text from another template</td>
		</tr>
	</tbody></table>
<p>For example:</p>
<pre lang="c++">#{Sample
  The solution's name is &lt;%SOLUTION%&gt;
  and the current project is &lt;%PROJECT%&gt;<br>
}#</pre>
<p>Will be expanded to:</p>
<pre lang="c++">  The solution's name is CodeTemplateNET
  and the current project is CodeTemplateNET
</pre>
<p>If an undefined keyword is used, then it's value is searched for in the system's 
	environment; if the environment variable is not found the keyword is replaced 
	with the empty string. For example:</p>
<pre lang="c++">#{User name
   Logged-in user name: &lt;%USERNAME%&gt;
}#</pre>
<p>Will be expanded to:</p>
<pre lang="c++">   Logged-in user name: velasqueze
</pre>
<p>When using nested templates using the <strong>template</strong> keyword, the 
	template that is being referenced must have a MenuID. For example:</p>
<pre lang="c#">#{Template A|tpla<br>// This is template A<br><br><br>}#</pre>
<pre lang="c#">#{Template B|tplb<br>// &lt;%template:tpla%&gt;<br>// This is template B<br><br>}#</pre>
<p>Ah, and by the way... recursive template nesting is a <strong>Bad Thing</strong>... 
	don't do it!</p>
<p>If the keyword's name starts with a <i><strong>question mark</strong></i> (<strong>?</strong>) 
	then the keyword represents a prompt value and it's name is used as the prompt 
	string in the input dialog. The prompt keyword name can contain spaces. For 
	example:</p>
<pre lang="c++">#{Ask me something
  &lt;%?Please answer the prompt%&gt;
}#</pre>
<p>Will be expanded to: (Supposing you typed "I just answered!" in the input box)</p>
<pre lang="c++">  I just answered!
</pre>
<p>The <i><strong>cursor position</strong></i> tag (<strong>%$%</strong>) will 
	reposition the caret after the text has been formatted and inserted in the 
	editor window.</p>
<h2>Formatters</h2>
<p>The value of a keyword can be modified by one or more <i>formatters</i>. 
	Formatters follow the keyword name and are separated by <i><strong>colons</strong></i>
	(<strong>:</strong>) and can have parameters.</p>
<p>Currently, the following formatters are predefined:</p>
<table id="formatters" cellspacing="0" cellpadding="1" width="100%" border="1">
	<tbody>
		<tr>
			<td valign="top" width="121"><strong>U</strong></td>
			<td valign="top" width="187">U[=start[,length]]</td>
			<td>Returns the key's value in uppercase. Start is zero-based.</td>
		</tr>
		<tr>
			<td valign="top" width="121"><strong>L</strong></td>
			<td valign="top" width="187">L[=start[,length]]</td>
			<td>Returns the key's value in lowercase. Start is zero-based.</td>
		</tr>
		<tr>
			<td valign="top" width="121"><strong>W</strong></td>
			<td valign="top" width="187">W=width</td>
			<td>Returns the key's value truncated to the parameter's width.</td>
		</tr>
		<tr>
			<td valign="top" width="121"><strong>R</strong></td>
			<td valign="top" width="187">R=str1[,str2]</td>
			<td>If only str1 is present, returns the key's value replacing the first character 
				with the second character in the parameter string. If str2 is also present, 
				returns the key's value replacing str1 with str2.</td>
		</tr>
		<tr>
			<td valign="top" width="121">
				<p><strong>FMT</strong></p>
			</td>
			<td valign="top" width="187">FMT=str</td>
			<td>
				<p>Returns the key's value formatted applying the parameter to 
					System.String.Format(). e.g. String.Format("{0:<em>str</em> }", key)</p>
			</td>
		</tr>
		<tr>
			<td valign="top" width="121" height="20"><strong>VALUES</strong></td>
			<td valign="top" width="187" height="20">VALUES=v1{, vn}*</td>
			<td height="20">Forces the prompt keyword to show up as a combobox with a 
				predefined list of values. Other values can be typed in.</td>
		</tr>
		<tr>
			<td valign="top" width="121"><strong>FIXEDVALUES</strong></td>
			<td valign="top" width="187">FIXEDVALUES=v1{, vn}*</td>
			<td>Forces the prompt keyword to show up as a combobox with a predefined list of 
				values. Only the values in the list can be used.</td>
		</tr>
		<tr>
			<td valign="top" width="121"><strong>MULTILINE</strong></td>
			<td valign="top" width="187">MULTILINE=int</td>
			<td>Forces the prompt keyword to show up as a multiline 
				textbox.&nbsp;The&nbsp;provided value indicates the height (in lines) of the 
				control.</td>
		</tr>
		<tr>
			<td valign="top" width="121"><strong>DRIVE</strong></td>
			<td valign="top" width="187">DRIVE</td>
			<td>Returns the drive part of the key's value</td>
		</tr>
		<tr>
			<td valign="top" width="121"><strong>DIR</strong></td>
			<td valign="top" width="187">DIR</td>
			<td>Returns the directory part of the key's value</td>
		</tr>
		<tr>
			<td valign="top" width="121"><strong>FNAME</strong></td>
			<td valign="top" width="187">FNAME</td>
			<td>Returns the file name part of the key's value</td>
		</tr>
		<tr>
			<td valign="top" width="121"><strong>EXT</strong></td>
			<td valign="top" width="187">EXT</td>
			<td>Returns the file extension part of the key's value</td>
		</tr>
		<tr>
			<td valign="top" width="121"><strong>PATH</strong></td>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -