indentation

Common coding style for Python?

Hi, I'm pretty new to Python, and I want to develop my first serious open source project. I want to ask what is the common coding style for python projects. I'll put also what I'm doing right now. 1.- What is the most widely used column width? (the eternal question) I'm currently sticking to 80 columns (and it's a pain!) 2.- What quot...

How to align C++ class member names in one column in emacs ?

I would like to align all C++ class member names ( do not confuse with member types ) in one column. Lets look at the example of what we have at entrance: class Foo { public: void method1( ); int method2( ); const Bar * method3( ) const; protected: float m_member; }; and this is what we...

A regular expression that moves opening { braces to a new line, for C/C++/PHP/etc code

This kind of code structure makes, IMHO, code less readable: int func() { [...] } It's just a matter of taste, but I prefer this one: int func() { [...] } So I've trying to make a regular expression to apply in my text editor in order to make code in the first example look like the second one. I've come up with something lik...

Text indent after the first line in a paragraph

- A Reuters reporter in Surkhrod district in Nangarhar province, where villagers said the raids took place, said Afghan police fired at the crowd after some of them started throwing stones at local government buildings. <p> - A Reuters reporter in Surkhrod district in Nangarhar province, where villagers said the raids took place, said ...

Textmate newbie question: how to indent CSS

New to TextMate and can't find the answer in the documentation. I've saved an empty file as CSS and the 'active bundle' is showing as CSS, at the bottom of the screen. I've then pasted in a bunch of CSS from elsewhere (a minified page). However, it's all pasted in as a single line. How can I indent it to look like 'proper' CSS, usi...

How to remove indentation highlighting in vim?

As I use vim, it tries to be helpful by highlighting groups of four spaces in yellow, as shown. My .vimrc file says, in its entirety, set tabstop=4. How can I keep vim from highlighting the indentation in my files? ...

XCode: Function argument indentation

I was unable to find any solution of my specific issue. I'm using Xcode 3.2. I'd like to indent the next line of function argument just one step in from the previous line: somevariable = pow( a, b); However, Xcode's syntax-aware indenting insists on converting the above into: somevariable = pow( a, ...

How to output formatted html in java

I'm reading an html file like this: try { BufferedReader bufferReader = new BufferedReader(new FileReader(path)); String content; while((content = bufferReader.readLine()) != null) { result += content; } bufferReader.close(); } catch (Exception e) { return e.getMessage(); } And I want to display it in ...

What is the "un-tab" sequence in (g)Vim?

This is an annoyance I've had for a long time. (Nitpicky section: I prefer 4 space characters to tab characters. It's a lot easier to type "tab" instead of explaining that. When I say "tab", I mean "the action that happens when you press the tab key" which is probably more simply stated as "increase indentation".) I'm using smartinde...

How to change Eclipse indentation style for automatically generated code?

Is there any way to change indentation style for automatically generated code in Eclipse? I'd like to change from class Test { blah blah } to class Test { blah blah } ...

Emacs: add do/while & if/else as exceptions to electric c mode (})

When c-auto-newline is set to non-nil, it re-indents the current line and inserts a carriage return and then indents the new line. However. I'm using 1TBS indent-style (with 4 space indents), which means if/else statements are made like this: if (n == 1) { exit(EXIT_SUCCESS); } else { perror("n"); } Also, I write do/while writ...

Using indentation to make CSS more readable? (making parents and children more identifiable in CSS)

I've been always guiding myself with the following CSS structure: #nav { } #nav li { } #nac li a { } This structure tells me clearly who is the parent and the child. But in a recent article (I think it was CSS Trick) someone said that CSS is read from right to left. So the more tags I had the slower it will be (and sometimes I think ...

strange error in haskell about indentation of if-then-else

I have the following code: foo :: Int -> [String] -> [(FilePath, Integer)] -> IO Int foo _ [] _ = return 4 foo _ _ [] = return 5 foo n nameREs pretendentFilesWithSizes = do result <- (bar n (head nameREs) pretendentFilesWithSizes) if result == 0 then return 0 -- <========================================== here is the error else...

Why doesn't Python require exactly four spaces per indentation level?

Whitespace is signification in Python in that code blocks are defined by their indentation. Furthermore, Guido van Rossum recommends using four spaces per indentation level (see PEP 8: Style Guide for Python Code). What was the reasoning behind not requiring exactly four spaces per indentation level as well? Are there any technical rea...

How do you indent preprocessor statements?

When there are many preprocessor statements and many #ifdef cascades, it's hard to get an overview since normally they are not indented. e.g. #ifdef __WIN32__ #include <pansen_win32> #else #include <..> #ifdef SOMEOTHER stmts #endif maybe stmts #endif When I consider also indenting those preprocessor statements, I fear of getting conf...

Specifying a no-indent for a list, with LaTeX

I have the following: This is just normal text... \begin{enumerate} \item First Item ?\\\\ This is the text of the first item \item Second Item ?\\\\ This is the text of the second item \end{enumerate} Which renders the following: This is just normal text... 1. First Item ? This is the text of the first item 2. Second Item ? ...

How do I indent/un-indent a QTextDocument?

What is the preferred way to indent/un-indent text in a list within a QTextDocument? Do I basically have to pass in the corresponding HTML tags myself? Edit: I'm looking for a way for the user to change the indentation level of a bulleted list with the Tab key. ...

Vim: Smart indent when entering insert mode on blank line?

When I open a new line (via 'o') my cursor jumps to a correctly indented position on the next line. On the other hand, entering insert mode while my cursor is on a blank line doesn't move my cursor to the correctly indented location. How do I make vim correctly indent my cursor when entering insert mode (via i) on a blank line? ...

Parsing Indentation-based syntaxes in Haskell's Parsec

I'm trying to parse an indentation-based language (think Python, Haskell itself, Boo, YAML) in Haskell using Parsec. I've seen the IndentParser library, and it looks like it's the perfect match, but what I can't figure out is how to make my TokenParser into an indentation parser. Here's the code I have so far: import qualified Text.Pars...

Visual Studio 2010 indentation after for loop.

Why am I getting this behavior right after the if block? Am I missing something? for (;;) if (/*...*/) { // statements } // statements indented to match the if indentation instead of the for loop; ...