code-formatting

Importance of Code Formatting Specificly Spacing

How important is it for readability that code be in this form: public void DoStuff() { var v = new Object(); v.PropertyID = "abc"; v.Type = "abc"; v.Style = "abc"; v.SetMode(Mode.Abc); v.Draw(); } vs. public void DoStuff() { var v = new Object(); v.PropertyID = "abc"; v.Type = "abc"; ...

In emacs XML mode, how to pretty-format an XML schema file?

I want to automatically format an XML schema definition file. All the normal pretty-print stuff: linebreaks after end-element, indentiing. I have seen this answer, and this elisp, which gives me the basics. Beyond what is there, though, I would like line-breaks between attributes within angle-brackets. Like so. Before: <s:schema el...

In emacs, how to line up equals signs in a series of initialization statements?

I saw this somewhere, but cannot find it now. Is there a built-in function in emacs, or does someone have elisp, to line up all the equals signs in a series of inititialization statments in cc-mode? Before: int t=9; Graphics g = new Graphics(); List<String> list = new List<String>(); After: int t = 9; Graphics g ...

how to align arguments to functions in emacs?

Say if I have the following: func(arg1, arg2, arg3...) func(longargarg1, longerarg2, arg3,...) ... How do I align the arguments so that it's like following? func(arg1 , arg2 , arg3...) func(longargarg1, longerarg2, arg3,...) ... [I can use M-x align-regex to align the first argument, but I cannot cook up with a suitable ...

Stand-alone Java code formatter/beautifier/pretty printer?

I'm interested in learning about the available choices of high-quality, stand-alone source code formatters for Java. The formatter must be stand-alone, that is, it must support a "batch" mode that is decoupled from any particular development environment. Ideally it should be independent of any particular operating system as well. So, a ...

How can I write a long regular expression so it fits on the screen?

I have match regular expresion in Perl. The match sentence that spreads over more than one line. I realize that I must enter the match regular expresion in one line only, if I spread to multiple lines it fails: $array_11 =~ m{By Steve (.*), MarketWatch LONDON (.*) -- Shares of Anglo American rallied on Monday morning as (.*) bet that t...

Define every symbol as a command in LaTeX

I'm working on a large project involving multiple documents typeset in LaTeX. I want to be consistent in my use of symbols, so it might be a nice idea to define a command for every symbol that has a specific meaning throughout the project. Does anyone have any experience with this? Are there issues I should pay attention to? A little mo...

code formatter for grails and Groovy?

I'm currently using a basic text editor to write my grails code. Does anyone know of a program that will automatically format code with indentation similar to indent does for C? I'd rather use a commandline program to do this but can use an IDE to format my code if that's the only option. ...

Is there an automatic source code formatter that nicely wraps lines of C/C++?

I use astyle to format my code most of the time, and I love it, but one annoyance is that it can't specify at least a "hint" for max line length. If you have a line of code like: this->mButtonCancel->setLeftClickProc(boost::bind(&FileListDialog::cancelLeftClick, this)); I would like a source code formatter to be able to wrap it even ...

my vs2008 addin for textformatting is awfully slow

Hi folks, i wrote a little addin, which does some formatting of my C# code. in the addins Exec method i do the following try { TextSelection selection = (EnvDTE.TextSelection)_applicationObject.ActiveDocument.Selection; String foo = String.Empty; if (!text.IsEmpty) { foo = someCoolObjectThatFormatsText.Format(...

using par for formatting comments in code with international characters

Hi, I'm using Par (in linux) to get nice comments formatting quickly. The problem is that now I want to introduce comments that include some international characters, like áéíóú or äëïöü... The program Berkeley Par considers these international characters as 2 ASCII characters (I believe) and it outputs the comments somehow broken beca...

Online Service to Cleanup HTML Formatting

There are plenty of services online that will color-code and "prettify" your code for you - I'm not interested in that for this question. I've taken over for a previous developer who loves seperating each line of markup with 3 or 4 empty lines, along with using spaces rather than tabs for indenting. This is very opposite to how I (and I ...

Is it possible to use Visual Studio HTML formatting to format an embedded code block?

I love Visual Studio's ability to auto format (CTRL + K,D). However, in HTML if you have something like: <h1><%# Eval("SomeField") %></h1> It gets formatted this way: <h1> <%# Eval("SomeField") %></h1> I'm fairly certain that the line break after the <h1> tag is caused by Visual Studio's formatting rules for embedded code bloc...

#ifdef #else #endif macro question

Hello, I am new to C, and I am maintaining someones code. I came across this in the header file. I can understand that if the source is compiled on the windows it will enter the if statement else if the code is compiled on a linux it will enter the else statement. Correct me if I am wrong. However, the question is why is # (hash) used ...

C# outlining. braces or regions

Hi I am maintaining a large asp.net app. My objective is to identify the lines added in response to particular tickets. While it is possible using our SVN, I want to put it in the code. because these changes would look just odd to a first time reader of the code. So which outlining method is more suitable for this purpose { //respons...

Should I use block identifiers ("end;") in my code?

Code Complete says it is good practice to always use block identifiers, both for clarity and as a defensive measure. Since reading that book, I've been doing that religiously. Sometimes it seems excessive though, as in the case below. Is Steve McConnell right to insist on always using block identifiers? Which of these would you use? ...

How to format source-code in a Framemaker document?

I have to write up a technical document in Framemaker that explains various programming source-code. So my document consists of a bunch of text, followed by a bunch of source code (Java, XML) and then followed by more text, etc. This question is not about whether I should or should not use Framemaker - that is the software I have to ...

Code Formatter: cleaning up horribly formatted jsp code

So I am working on a jsp/servlet that came to me and I'm looking at the jsp file and it is just a jungle of jstl tags, java code and html thrown together. At first it looked like someone ran the standard eclipse formatter on it and had the page width set to 40 so alot of stuff is broken up, I tried to format it with a larger page width b...

HTML Formatting

Hey all, I have to make a few changes to some unformatted HTML (no line breaks, nothing) and was wondering if there are any web-based or open source tools that will automatically format it so it's easier to read. Thanks! ...

Command line formatter for PHP and Javascript

Are there any command line (not interactive, not web-based) tools that will reformat (pretty-print) PHP and Javascript code? ...