indentation

unexpected indent in ipython 0.10.1

自闭症网瘾萝莉.ら 提交于 2019-12-07 12:19:26
问题 I have a problem with ipython 0.10.1 in ubuntu 11.04 and python 2.7.1. In previous versions of ipython indentation did not matter when working interactively. Now instead any indented statement throws an exception: In [1]: a=3 ------------------------------------------------------------ IndentationError: unexpected indent (<ipython console>, line 1) this is really very annoying specifically when I am debugging and I want to paste some code from a script which is indented, and I am forced to

Parsing python with PLY, how to code the indent and dedent part

孤人 提交于 2019-12-07 11:32:08
问题 I was trying to parse the function definition for the python language with PLY. I am encountering issues related to the indentation. For instance for a for statement, I would like to be able to know when the block ends. I read the python grammar here: http://docs.python.org/2/reference/grammar.html And the grammar for this part is: for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT I don't know how to describe the INDENT and

How to save XmlDocument with multiple indentation settings?

痴心易碎 提交于 2019-12-07 05:30:15
问题 I need to save one XmlDocument to file with proper indentation (Formatting.Indented) but some nodes with their children have to be in one line (Formatting.None) . How to achieve that since XmlTextWriter accept setting for a whole document? Edit after @Ahmad Mageed's resposne: I didn't know that XmlTextWriter settings can be modified during writing. That's good news. Right now I'm saving xmlDocument (which is already filled with nodes, to be specific it is .xaml page) this way: XmlTextWriter

Generating an indented string for a single line of text

◇◆丶佛笑我妖孽 提交于 2019-12-07 04:59:17
问题 What is the best way to generate an indented line from space characters. I mean something similar to this: string indent = String.Join(" ", new String[indentlevel]); s.Write(indent + "My line of text"); 回答1: You can create your indention with this: var indent = new string(' ', indentLevel * IndentSize); IndentSize would be a constant with value 4 or 8. 回答2: I would probably do something like this to add Indent . public static string Indent(int count) { return "".PadLeft(count); } To use it

Emacs indentation for html (web-mode) doesn't work properly

二次信任 提交于 2019-12-07 04:59:15
问题 I'm using web-mode in Emacs to get syntax highlighting and indentation for PHP and HTML. If I have this code in a .php file <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p> And then put the cursor on the middle line and press tab then nothing happens. I want it to look like this: <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p> If I put the text in a tag on a single line and try to indent, it works. This: <p> <a>Lorem ipsum dolor sit amet, consectetur

Wrong array initializer indentation while typing PHP in Eclipse

旧时模样 提交于 2019-12-07 02:15:35
问题 I set my preferred array initializer indentation on Preferences > PHP > Code Style > Fromatter > Line Wrapping, but while typing array initializers indentation is wrong: $arr = array([ENTER] ····[CURSOR]) while I'm expecting: $arr = array([ENTER] ··[CURSOR] ) like it happens editing Javascript code. Note that the wrong indentation happens only while typing, whereas an explicit CTRL+SHIFT+F indents array initializer correctly. (So not a duplicate of many other questions asking how to set

Show Indent Guide Lines In Xcode

拈花ヽ惹草 提交于 2019-12-07 00:21:26
问题 Coming from a background using Visual Studio and Notepad++ I'm used to the indent guides which help to visually enhance sections of code where the curly braces are used, Xcode (No indent guides) Visual Studio (Nice tidy indent guides) As you can see from the images above sometimes there are sections of code where multiple levels of curly braces are open and it gets messy without any indent guides. Are there any options or plugins that will allow xcode to display the indent guides in between

PHP correct indentation?

自闭症网瘾萝莉.ら 提交于 2019-12-06 20:36:15
问题 I'm a beginner PHP coder, recently I've been told I indent my code not correctly. They say this is wrong: if($something) { do_something(); } else { something_more(); and_more(); } While this is right? if($something) { do_something(); } else { something_more(); and_more(); } Really? I am willing to become opensource coder in nearest future so that's why I'm asking how to write code in a good way. 回答1: Both ways will run just fine. Whichever is more comfortable for you and your team would be

Java 1.6: javax.xml.transform.Transformer refuses to indent xml strings which contain newlines

懵懂的女人 提交于 2019-12-06 08:10:30
I need to be able to pretty print xml strings using Java APIs and have found multiple solutions for this both on the web and on this particular website. However despite multiple attempts to get this to work with javax.xml.transform.Transformer it's been a failure so far. The code I provide below works only partially when the xml string in the argument does not contain any newlines between xml elements. This just wont do. I need to be able to pretty print anything, assuming it is well formed and valid xml, even previously pretty printed strings. I got this (put together from code snippets I

Qt Mode for Emacs

人盡茶涼 提交于 2019-12-05 22:44:48
What are you using to develop Qt code in Emacs, so that it's highlighted/indented properly? This page explains an extension to CC mode, but it seems a little outdated. Since Qt is constantly evolving, is there a more up-to-date Qt mode available? That page makes it pretty clear that the standard cc-mode packaged with GNU Emacs is supporting Qt extensions now; just make sure your cc-mode is up to date and you should be all set. 来源: https://stackoverflow.com/questions/6144512/qt-mode-for-emacs