理想与现实之间

学习的最好方法就是blog

博客园 首页 新随笔 联系 订阅 管理
  68 Posts :: 2 Stories :: 426 Comments :: 12 Trackbacks

公告

2004年11月3日 #

如果你不清楚VS 2005的定制Code Expansion的功能,可以看一下我的这篇文章

第一个是用来生成string,其实就是自动生成一对双引号,在中间输入好string之后,按回车可以跳到双引号之后。这个是受了eclipse的启发,不过觉得我的这个更好用,因为输入完字符串之后,不用去按方向键,嘿嘿
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippet Format="1.0.0">
    
<Header>
        
<Title>String</Title>
        
<Shortcut>s</Shortcut>
        
<Description>Expansion snippet for String</Description>
        
<SnippetTypes>
            
<SnippetType>Expansion</SnippetType>
        
</SnippetTypes>
    
</Header>
    
    
<Snippet>
        
<Declarations>
            
<Literal>
                
<ID>body</ID>
                
<ToolTip>string body</ToolTip>
            
</Literal>
        
</Declarations>
        
<Code Language="csharp" Format="CData"><![CDATA["$body$"$end$]]>
        
</Code>
    
</Snippet>
</CodeSnippet>


第二个是用来生成一个函数的框架,写这个的原因主要是eclipse里面,打一个大括号会自动生成另一个,实在是很好的功能,这样就不会去按方向键了。
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippet Format="1.0.0">
    
<Header>
        
<Title>Function</Title>
        
<Shortcut>f</Shortcut>
        
<Description>Expansion snippet for Function</Description>
        
<SnippetTypes>
            
<SnippetType>Expansion</SnippetType>
        
</SnippetTypes>
    
</Header>
    
    
<Snippet>
        
<Declarations>
            
<Literal default="true">
                
<ID>modifier</ID>
                
<ToolTip>modifier of a function</ToolTip>
                
<Default>void</Default>
            
</Literal>
            
<Literal default="true">
                
<ID>name</ID>
                
<ToolTip>function name</ToolTip>
                
<Default>foo</Default>
            
</Literal>
            
<Literal default="true">
                
<ID>arg</ID>
                
<ToolTip>argument list</ToolTip>
                
<Default>int i</Default>
            
</Literal>
        
</Declarations>
        
<Code Language="csharp" Format="CData"><![CDATA[$modifier$ $name$($arg$)
        {
            $end$
        }
        
]]>
        
</Code>
    
</Snippet>
</CodeSnippet>

这个东东有一个BUG,本来想让那个argument list默认显示空白的,但是不知道为什么默认空白,那个输入区域就没了,只好搞了一个int i,下次再写一个无参的方法框架。

有了这两个,再加上系统原有的那些Code Expansion,按方向键的需求已经降到了最低,我觉得我有越来越懒的趋势。
posted @ 2004-11-03 22:56 Justin Shen 阅读(1473) 评论(6) 编辑

我在私有新闻组里询问VC2005里是不是会有Refactoring或者Code Expansion的功能,结果得到如下的回复,真是十分遗憾:


Unfortunately, we won't be able to support refactoring or code expansion in
the Whidbey timeframe.  However, we will definitely be revisiting and
considering the feature set for our next release.  It's an important
customer request, and we'd like to implement it if possible.

--
cheers,
Ami Vora
Program Manager, Visual C++

posted @ 2004-11-03 19:47 Justin Shen 阅读(1512) 评论(1) 编辑