Jim*_*eth 44 c# resharper refactoring visual-studio-2008 code-snippets
我总是发现自己需要在花括号{}中包含一段代码,但不幸的是,它不包含在C#环绕声代码片段中,这似乎是一种疏忽.我也找不到任何建立你自己的环绕片段的东西(只是其他类型的片段).
我实际上也在运行Resharper,但它似乎也没有这个功能(或者我还没想过如何激活它).
我们拥有包括编码标准的代码,甚至单行的之后,如果还是别人的大括号,所以如果我可以只让ReSharper的做自动重构会更加美好!
Igo*_*aka 50
这是一个快速而又脏的代码片段.
安装:
将代码保存SurroundWithBraces.snippet
为"<my documents>\Visual Studio Version\Code Snippets\Visual C#\My Code Snippets"
使用:
选择文本块.
按Ctrl+K, Ctrl+S
Chose My Code Snippets,大括号
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>braces</Title>
<Shortcut>braces</Shortcut>
<Description>Code snippet to surround a block of code with braces</Description>
<Author>Igor Zevaka</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="csharp">
<![CDATA[{
$selected$ $end$
}]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Run Code Online (Sandbox Code Playgroud)
Ray*_*ega 37
在ReSharper 4.5中,花括号作为内置的"环绕模板"之一包含在内:
ReSharper -> Code -> Surround
With... -> {}
要么
ALT + R -> C -> S -> 7
要么
Ctrl+E, U -> 7
(Visual Studio方案)
要么
Ctrl+Alt+J -> 7
(ReSharper 2.x/IDEA计划)
Jim*_*mmy 19
怎么样:
Ctrl-X, {, Ctrl-V, }
Run Code Online (Sandbox Code Playgroud)
你甚至可以将它绑定到宏.
归档时间: |
|
查看次数: |
16109 次 |
最近记录: |