code-formatting

How to format perl code?

I really like my Perl code formatted - lines indented, etc. The problem is I hate doing it myself, and I really enjoy auto-formatters that do this automatically for you. I work with Eclipse and the EPIC plugin does just that. The problem is that it does not handle comments very well. If comments are too long, it does not break them into...

Uncrustify, how to force opening braces to share the previous code line?

Using the Uncrustify tool I would like to apply the 1TBS style, which places braces like this: if (x < 0) { printf("Negative"); } How do I do this? I can't seem to find the right options. ...

Visual Studio/ReSharper: How to wrap long lines with commas before params?

I've been customizing my formatting desires using ReSharper for code clean-up. So far I've been able to make the clean-up rules match my coding style within:      ReSharper -> Options -> Languages -> C# -> Formatting Style One thing I haven't figured out how to do yet is how to have params/fields/list items wrap with leading commas inst...

What R# setting is reformatting this line?

VS2010 / R#5.1 I have this "line" of code: With.Mocks(_mocks).Expecting(() => { _fooServiceMock.Expect(x => x.FooMethod()).Return(fooMockData); }).Verify(() => { }); I perform a R# code cleanup, which changes the code as follows: With.Mocks(_mocks).Expecting(() => { _fooServiceMock.Expect(x => x.FooMethod()).Return(fooMockData)...

Split Ruby regex over multiple lines

This might not be quite the question you're expecting! I don't want a regex that will match over line-breaks; instead, I want to write a long regex that, for readability, I'd like to split onto multiple lines of code. Something like: "bar" =~ /(foo| bar)/ # Doesn't work! # => nil. Would like => 0 Can it be done? ...

Can I run the Eclipse c++ Formatters from the command line

I found this page which shows how to run the Java formatter but I cannot find similar resources to run the built-in C/C++ formatters. It is possible To do this? ...

Format ruby code in vim

Just moving over to vim at the moment. In textmate I could format code by hitting cmd-alt-[. How do I achieve the same in vim? See the answer below for the command. I found I also need the following in my vimrc so that vim new how to autoindent ruby. if has("autocmd") filetype indent on endif ...

C/C++ Checking for NULL pointer

In a recent code review, a contributor is trying to enforce that all NULL checks on pointers be performed in the following manner: int * some_ptr; // ... if( some_ptr == NULL ) { // handle null-pointer error } else { // proceed } instead of int * some_ptr; // ... if( some_ptr ) { // proceed } else { //handle null-pointer err...

Is there a way to prevent Visual Studio 2010 formatting C# code in ASP.NET MVC views?

I'd like Visual Studio to continue automatically formatting my .cs files, but is there a way to prevent it auto-formatting C# code in between the <% %> tags in ASP.NET MVC views because it really makes a mess of it? ...

How to format code with IntelliJ?

I know, it sounds really stupid, but I don't seem to be able to format my code in IntelliJ. I can see the margin line (by default at 120 columns) but it seems that the formatter (activated from the menu Code -> Reformat Code) is just ignoring this margin. I'm quite new to IntelliJ so probably I'm just missing something trivial. It's qui...

How can I make perltidy work with Method::Signatures?

I'm using Eclipse combined with EPIC to write my Perl code. I configured EPIC to use Perltidy with "-pbp" (perl best practices style) to format my code. This doesn't work well when using Method::Signatures' named parameters. E.g., func (:$arg1, : $arg2) is formatted as func (: $arg1, : $arg2) which yields an error. Also, func keyword i...

What applications do you know of, that can reformat code?

Hello, I am looking for a list of code formatting and prettifying software; I have only found a few topics that all are language specific. This is not about syntax highlighting! If possible, I prefer lightweight, command-line, multiplatform, portable tools. Nevertheless, if there is no interesting alternative, I also like to know what...

Flexible C code formatter software

I'm looking for a very flexible C code formatting solution. Here's the context: I need to convert some external C code to my organization's "coding rules". For example, these rules demand that I put the type of each variable in its name (int_foo, pfloat_bar, etc.). Most of these rules are completely absurd but I don't have a choice. I ...

JavaScript formatting: must braces be on the same line as the if/function/etc keyword?

Possible Duplicate: why results varies upon placement of curly braces in javascript code We have company policies that dictate that in PHP opening curly braces should be on their own lines for readability and so that they can line-up with the closing brace; thus: if (true) { ... } but in JS they should be kept on the s...

how to properly format code in notepad++?

I have notepad++ and I got a xml code which is very long and when I pasted it in notepad++ there is a long line of code. (difficult to read and work.) Now, I want to know if there is a simple way to make the text readable. (by readable I mean properly tabbed code) I can do it manually but want a permanent solution to this, as I have face...

What is the correct way to break a line of Perl code into two?

$ cat temp.pl use strict; use warnings; print "1\n"; print "hello, world\n"; print "2\n"; print "hello, world\n"; print "3\n"; print "hello, \ world\n"; $ perl temp.pl 1 hello, world 2 hello, world 3 hello, world $ To make my code easily readable, I want to restrict the number of columns to 80 characters. How can I break a line of...

python "best practice" for lists/dictionary etc

Been looking over the python docs for code formatting best practice for large lists and dictionaries, eg something = {'foo' : 'bar', 'foo2' : 'bar2', 'foo3' : 'bar3'..... 200 chars wide etc..} or something = {'foo' : 'bar', 'foo2' : 'bar2', 'foo3' : 'bar3', ... } or something = {...