views:

277

answers:

4

Whenever I create a method signature in VS 2008 (C#), I type the two braces:

public void Something() {}

This leaves the cursor to the right of the closing brace. Then I have to use the arrow keys to reposition the cursor in between the braces. Is there a better way to do this without using the arrow keys?

I'd expect it to place the cursor in between the braces when I type the closing one so I can start typing code.

+2  A: 

I believe Resharper does this. Not sure if there is a free option.

Kent Boogaart
A: 

You could record a macro that inserts the } then moves the cursor and then assign the macro to the shift+] key combo, so that your closing curly bracket always performs your macro.

Greg
A: 

CodeRush does this as well.

John Kraft
+2  A: 

I don't have vs2008 at the moment. Assuming VS2008 still supports this, you could use code snippets. Mess with below til you get what you need. (See Tools|Code Snippets Manager)

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"&gt;
    <CodeSnippet Format="1.0.0">
     <Header>
      <Title>b</Title>
      <Shortcut>b</Shortcut>
      <Description>Braces with cursor inside</Description>
      <Author>CrashCodes</Author>
     </Header>
     <Snippet>
      <Code Language="csharp"><![CDATA[{
         $end$
      }]]>
      </Code>
     </Snippet>
    </CodeSnippet>
</CodeSnippets>
CrashCodes
correct answer (+1)
Juri