469,903 Members | 2,138 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

Option to turn off brace placement enforcement in IDE?

Hi, Group,

I prefer indenting braces with their block, thus:

public int Foo()
.....{
.....Bar();
.....}

[using dots because I know newsreaders tend to mess up whitespace]

But when I copy and paste such code in the IDE, it "fixes" the brace
placement for me, thus:

public int Foo()
{
.....Bar();
}

Please, leaving aside the issue of which way is "better", is there any
way to turn off this behavior? I'm happy to report that drag and drop,
at least, doesn't mess up my indentation.

Peace,
--Carl

Nov 16 '05 #1
4 1126
Go to Tools->Options and select the C# editor in the left pane, then the
Formatting node.

Fiddling with these settings will certainly make the formatting change. I
don't think you can force it to do any more than not format what you've put
in though. Try uncheking "Automatically format completed constructs and
pasted source"

Checking "Leave open braces on same line as construct" gives you

if(thing)
{blah;
}

(ugh.... nasty!)

Your best bet is to not fight it and conform.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

<ca***********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi, Group,

I prefer indenting braces with their block, thus:

public int Foo()
....{
....Bar();
....}

[using dots because I know newsreaders tend to mess up whitespace]

But when I copy and paste such code in the IDE, it "fixes" the brace
placement for me, thus:

public int Foo()
{
....Bar();
}

Please, leaving aside the issue of which way is "better", is there any
way to turn off this behavior? I'm happy to report that drag and drop,
at least, doesn't mess up my indentation.

Peace,
--Carl

Nov 16 '05 #2
Carl,

Have you checked under the options for the editor for C#? Under "Tools
| Options", then go to "Text Editor | C# | Formatting | General", there
should be an option called "Adjust indentation on paste". Uncheck that, and
you should be fine.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<ca***********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi, Group,

I prefer indenting braces with their block, thus:

public int Foo()
....{
....Bar();
....}

[using dots because I know newsreaders tend to mess up whitespace]

But when I copy and paste such code in the IDE, it "fixes" the brace
placement for me, thus:

public int Foo()
{
....Bar();
}

Please, leaving aside the issue of which way is "better", is there any
way to turn off this behavior? I'm happy to report that drag and drop,
at least, doesn't mess up my indentation.

Peace,
--Carl

Nov 16 '05 #3
Thanks, Nicholas,

In my version the option is under

Text Editor | C# | Formatting

and is called

Automatically format completed constructs and pasted source

, but that certainly does the trick. Don't know why I didn't see it
myself. Thanks!

Peace,
--Carl

Nov 16 '05 #4
Thanks, Bob,

That does the trick.
Your best bet is to not fight it and conform.


I'm happy to conform to the standards of the team I'm working on, but
when the team is just me, I hate to be dictated to by a piece of
software.

Peace,
--Carl

Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Microsoft News | last post: by
23 posts views Thread by Giancarlo Niccolai | last post: by
20 posts views Thread by Ioannis Vranos | last post: by
5 posts views Thread by Lagarde Sébastien | last post: by
15 posts views Thread by LuB | last post: by
9 posts views Thread by karthikbalaguru | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.