jQuery and ASP.NET

June 21, 2010

Place Opening Braces in a New Line for a JavaScript function – Visual Studio 2010




Developers have different way of indenting JavaScript code in Visual Studio 2010. When it comes to methods, some of them keep the opening braces in the same line of the method declaration like this:

<script type="text/javascript">
function
someFun() {
}
</script>

This is also the default indentation in Visual Studio 2010. If you want to change that and place opening braces in a new line, then Go to Tools > Options > Text Editor > JScript > Formatting > Check the box ‘Place open brace on new line for functions’

image

Now when you type the same function and hit enter before the last braces, Visual Studio indents the opening braces on a new line as shown below

<script type="text/javascript">
function
someFun()
{
}
</script>



'Like' us on our FaceBook page if you find this blog useful. Thanks!


Did you like this post?
kick it on DotNetKicks.com Save on Delicious
subscribe via rss subscribe via e-mail
print this post follow me on twitter


About The Author

Suprotim Agarwal, ASP.NET Architecture MVP works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He has also written an EBook 51 Recipes using jQuery with ASP.NET Controls.

Follow him on twitter @suprotimagarwal

comments

1 Response to "Place Opening Braces in a New Line for a JavaScript function – Visual Studio 2010"
  1. Anonymous said...
    October 18, 2011 7:24 AM

    Good. Thanks for sharing.

 

Copyright © 2009-2011 All Rights Reserved for DevCurry.com by Suprotim Agarwal | Terms and Conditions