indentation

Indenting entire file in Vim without leaving current cursor location

房东的猫 提交于 2019-11-29 04:28:30
I already know that gg=G can indent the entire file on Vim. But this will make me go to the beginning of the file after indent. How can I indent the entire file and maintain the cursor at the same position? See :h '' This will get you back to the first char on the line you start on: gg=G'' and this will get you back to the starting line and the starting column: gg=G`` I assume the second version, with the backtick, is the one you want. In practice I usually just use the double apostrophe version, since the backtick is hard to access on my keyboard. Add this to your .vimrc function! Preserve

How to catch IndentationError [duplicate]

泄露秘密 提交于 2019-11-29 04:01:50
This question already has an answer here: SyntaxError inconsistency in Python? 2 answers First of all - I don't have a problem with bad-indentated code and I have an idea of how does this exception works like. I ask, if there is any way to catch IndentationError in code with a try/except block? For example, let's say I'm writing a test for a function written by someone else. I want to run it in try/except block and handle all warning he/she could make. I know, that it's not a best example, but the first one coming to my mind. Please, don't focus on an example, but rather on problem. Let's look

editing the NetBeans source formatting standard

一世执手 提交于 2019-11-29 03:04:34
Is there any way of changing the standard by which NetBeans automatically formats the code when doing "Source->Format"? I seem to remember seeing this option somewhere, but I can't find anything about it. You can change a very limited number of settings related to formatting. open up netbeans IDE Go to tools->options click on Editor button on top left of the options dialog box click on the formatting tab select PHP from the language select box then you would be able to see the required settings that can be changed. Latest version 7.3 will solve most of your needs. The formatting preferences

Automatic indentation for Python in Notepad++

一个人想着一个人 提交于 2019-11-29 02:53:54
I've been googling lots and this is getting really frustrating. It doesn't act like idle. Example: else: name = 'World' print 'Howdy', name print 'yay' but in Notepad++ else: # i press enter and this is what it does lands me here But I want to be able to do like in idle: after the : I can just press enter and keep on going. My English isn't that great. I have my filetype set to Python etc. and my format to unix. This is what you want: Settings > Preferences > MISC. > Auto-Indent (checkbox) -- Sometimes people ask, "How can I do x in program y?" I have a dream that one day "Use program z

Is it possible to set indent settings in Xcode per project (or per file, even)?

泄露秘密 提交于 2019-11-29 01:23:34
问题 Some projects I work in uses tab key settings that equate to 3 or 4 spaces and another wants actual tabs. Another mixes the two depending on directory. Is there some way to set these settings per project, or even better, per file? If not, does someone have a clever way of dealing with this? (besides "just remember which setting you should use and change it before you start editing") 回答1: Update: This answer only applies to Xcode3. For newer versions, see James Turner's answer. Yes, go to View

Custom indent width for BeautifulSoup .prettify()

依然范特西╮ 提交于 2019-11-29 01:05:13
Is there any way to define custom indent width for .prettify() function? From what I can get from it's source - def prettify(self, encoding=None, formatter="minimal"): if encoding is None: return self.decode(True, formatter=formatter) else: return self.encode(encoding, True, formatter=formatter) There is no way to specify indent width. I think it's because of this line in the decode_contents() function - s.append(" " * (indent_level - 1)) Which has a fixed length of 1 space! (WHY!!) I tried specifying indent_level=4 , that just results in this - <section> <article> <h1> </h1> <p> </p> <

Getting vim to recognize XML

主宰稳场 提交于 2019-11-28 23:09:13
I would like vim to help me indent my xml files like my C code. However, when I use gg=G It just sets everything to the left. Do I need to designate a syntax? Is XML recognized as a language? Idan Arye Put filetype plugin indent on in your .vimrc to have Vim automatically identify .xml files as xml. You might need to put set nocompatible before that. If the file extension is not .xml, you can make Vim threat it like xml by using :set filetype=xml After you do that, Vim's autoindention (and syntax highlighting, and omnicomplete (that in xml just closes tags, but that's still something)) will

Smart Indent algorithm documentation?

让人想犯罪 __ 提交于 2019-11-28 22:56:24
问题 I'm a big fan of documenting the proper behavior of IDE features that have a subtle but significant impact on coding flow - things like auto-completion selection and commenting/uncommenting code you might not realize you take advantage of but at the end of the day you got just a bit more done than you might have. I do so in hopes that other language services I have to use incorporate the feature(s), subsequently improving my daily coding life. "Real" Smart Indent, i.e. the Visual Studio 2008

How to paste source code to vim without error format?

丶灬走出姿态 提交于 2019-11-28 22:29:39
问题 When I copy a python code, and paste to vim. the indents are all error. but I paste into emacs or gedit, it is right. that is difficult to describle, let's see the screenshot. Notice:the blue and yellow line is just use the "indent guides plugin". This is the source code example: import threading import time class timer(threading.Thread): #The timer class is derived from the class threading.Thread def __init__(self, num, interval): threading.Thread.__init__(self) self.thread_num = num self

How I can increase tab width in notepad++ (v6.5)?

馋奶兔 提交于 2019-11-28 21:49:53
问题 This is example of two 4-space indentations http://i.imgur.com/B2BWYSw.png But indentation from notepad++ narrower with same number of spaces How I can change it? 回答1: In version 7.2.2, the Tab Settings are under: Settings > Preferences > Language > Tab Settings 回答2: Notepad++ newest version, as of 2/24: Settings > Preferences > Language > Tab Settings. It's the blue, underlined value labeled "Tab Size:", just click it. 回答3: For versions prior to v7, you can find the option under: Preferences