473,396 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 1219
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Microsoft News | last post by:
I have a project that was created all with Option Strict OFF. Works great, not a problem with it. But if I turn Option Strict ON then I get a LOT of errors. My question, should I even care...
23
by: Giancarlo Niccolai | last post by:
Hello all. I have peeked through the FAQ and all relevant links, and also through Stroustrup book, but I have not been able to find an answer, so I have to post here as a last resort. It...
20
by: Ioannis Vranos | last post by:
When we use the standard placement new operator provided in <new>, and not a definition of owr own, isn't a call to placement delete enough? Consider the code: #include <new>
4
by: Jason Kendall | last post by:
How do I use a curly brace within a string passed to String.Format? I want to pass a string that includes a curly brace, but that curly brace is not being used to indicate a replacable format...
17
by: David | last post by:
Hi all, I have the following problem: my program works fine, but when I add option strict at the top of the form, the following sub fails with an error that option strict does not allow late...
5
by: Lagarde Sébastien | last post by:
Hello, I write code to debug new call with following macro: #define new (MemoryManager::Get().setOwner (__FILE__, __LINE__, _FUNCTION-), FALSE) ? NULL : new The setOwner allow to save the...
15
by: LuB | last post by:
I am constantly creating and destroying a singular object used within a class I wrote. To save a bit of time, I am considering using 'placement new'. I guess we could also debate this decision -...
9
by: karthikbalaguru | last post by:
Hi, I find that articles stating that 'placement new' constructs an object on a pre-allocated buffer and so takes less time. Actually, we have to consider the allocation of the buffer and then...
25
smithj14
by: smithj14 | last post by:
I have a form that has an option group (fraReports) which holds a list of reports to print. This part works fine. I select a report name and click print and that report opens. Now I want to add a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.