indentation

Vim automatically removes indentation on Python comments [duplicate]

两盒软妹~` 提交于 2019-11-28 03:38:23
This question already has an answer here: How to configure vim to not put comments at the beginning of lines while editing python files 8 answers I'm using Vim and editing Python scripts. Autoindent works pretty well in general, but when I start a new line and type '#' to type a comment, Vim unindents that line for me. For example, if have def foo(): and I press enter, Vim will indent properly def foo(): pass but, if instead of typing pass , I type # , it unindents automatically def foo(): # comment class Thing(): def __init__(self): pass # comment line gets unindented all the way my .vimrc

Emacs C++-mode incorrect indentation?

放肆的年华 提交于 2019-11-28 03:15:59
I'm running emacs 23 with c++-mode and having some indentation problems. Suppose I have this code: void foo() { if (cond) { <--- int i; ... } <--- } This seems to be the default behavior of the automatic indentation. However I'd like to change it so it'll be like this: void foo() { if (cond) { int i; ... } } Is there a way to do this easily by configuring c++ mode or my .emacs file? I have the following in my .emacs file: (defun my-c++-mode-hook () (setq c-basic-offset 4) (c-set-offset 'substatement-open 0)) (add-hook 'c++-mode-hook 'my-c++-mode-hook) You can determine which offset to edit by

How to automatically indent source code?

自闭症网瘾萝莉.ら 提交于 2019-11-28 03:07:27
How can I automatically indent source code in Visual Studio 2010? I have used Ctrl + K , Ctrl + F , but it does not work; is there any other way/plugin to do this? Thomas Weller Ctrl + E , D - Format whole doc Ctrl + K , Ctrl + F - Format selection Also available in the menu via Edit|Advanced . Thomas Edit- Ctrl + K , Ctrl + D - Format whole doc in VS 2010 gooddadmike In 2010 it is Ctrl + k , Ctrl + d . See image below. Armaan In Visual Studio 2010 Ctrl + k + d indent the complete page. Ctrl + k + f indent the selected Code. For more help visit : http://msdn.microsoft.com/en-us/library

How do I make xsl transformation indent the output?

ぐ巨炮叔叔 提交于 2019-11-28 02:57:42
问题 I'm using xalan with the following xsl header: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:redirect="http://xml.apache.org/xalan/redirect" extension-element-prefixes="redirect" xmlns:xalan="http://xml.apache.org/xalan"> <xsl:output method="text" indent="yes" xalan:indent-amount="4"/> And the output is not indented. Anyone with ideas? 回答1: For indentation you need to use a different namespace: "http://xml.apache.org/xslt" (see this issue) <xsl

Why don't people indent C++ access specifiers/case statements?

孤街醉人 提交于 2019-11-28 02:28:04
问题 I often see stuff like this: class SomeClass { public: void someMethod(); private: int someMember; }; This seems totally unnatural to me (the same applies to case -statements when using switch ). I expected something like this, when i started using C++ (it's been a long time since then, but i am still wondering): class SomeClass { public: void someMethod(); private: int someMember; }; Is there a funded reason to break (otherwise) consistent indentation rules? 回答1: Increasing indentation

Tab Error in Python

心已入冬 提交于 2019-11-28 02:18:14
The following python code throws this error message, and I can't tell why, my tabs seem to be in line: File "test.py", line 12 pass ^ TabError: inconsistent use of tabs and spaces in indentation My code: class eightPuzzle(StateSpace): StateSpace.n = 0 def __init__(self, action, gval, state, parent = None): StateSpace.__init__(self, action, gval, parent) self.state = state def successors(self) : pass You cannot mix tabs and spaces, according the PEP8 styleguide : Spaces are the preferred indentation method. Tabs should be used solely to remain consistent with code that is already indented with

Emacs indent level global override

痞子三分冷 提交于 2019-11-28 01:22:14
问题 I want to set the indentation mode to tabs only, with a 4 character width for any mode. This seems like a trivial thing, but I have not had success. Every mode seems to have its own variables and options. I've tried doing this for Perl and R without success. Things that have not worked: (setq-default tab-width 4) (setq standard-indent 4) (setq-default r-indent-level 4) (setq perl-indent-level 4) (setq c-basic-offset 4) works for c-mode but nothing else. Am I forgetting something? Did I set

Indentation in generated PDF using JasperReports

﹥>﹥吖頭↗ 提交于 2019-11-28 01:09:19
I have a piece of HTML stored in a database as: <ul> <li>Pretend you're talking to a busy colleague and have to sum up your entire question in one sentence: what details can you include that will help someone identify and solve your problem?</li> <li>Spelling, grammar and punctuation are important! Remember, this is the first part of your question others will see - you want to make a good impression. If you're not comfortable writing in English, ask a friend to proof-read it for you. </li> <li>If you're having trouble summarizing the problem, write the title last - sometimes writing the rest

Python IndentationError unindent does not match any outer indentation level

北慕城南 提交于 2019-11-28 00:21:56
问题 I'm a beginner in python , I have this error : Error : def on_data(self,data): ^ IdentationError : unindent does not match any outer indentation level I code with notepad++ in windows 8.1 . I don't understand why I have this error, I have paid attention about tabs and space. I want to save data in self.file Here is my code : from tweepy import OAuthHandler from tweepy.streaming import StreamListener from tweepy import Stream import tweepy import time class StdOutListener(StreamListener): def

Vim: gg=G aligns left, does not auto-indent

风格不统一 提交于 2019-11-27 23:44:05
When I try to fix the indentation of an HTML file with gg=G , each line loses its indentation and becomes left-justified. Does anybody know what could be going on here? test.html <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>Indent test</title> </head> <body> <div id="test"> <div id="test2"> </div> </div> </body> </html> test.html after running gg=G: <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>Indent test</title> </head> <body> <div id="test"> <div id="test2"> </div> </div> </body> </html> .vimrc ".vimrc "