many of time I have a if condition with just one line, like this:
if (true)
// my single code
but sometimes, I want to expend my if condition to 2 or more codes, so I should use braces.
if (true)
{
//do something
}
I want to know is there any shortcut for change first code to second one?
You could create a code snippet that surrounds the selected text like this:
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>curls</Title>
<Description>Puts curly braces around the selected text.</Description>
<Author>Erik Venema</Author>
<SnippetTypes>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="CSharp">
<![CDATA[{
$selected$
$end$
}]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Save it as curls.snippet and import it in the code snippet manager.
After that you can use the snippet by selecting the text, press CTRL-K
+CTRL-S
and select the curls snippet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With