indentation

Emacs ruby-mode indentation behavior

北城余情 提交于 2019-11-27 14:04:56
问题 class Foo attr_accessor :a, :time, # ms since epoch :b, :c end In text mode, the variables listed after 'a' would indent as written above, but in ruby mode they would instead be flush with 'attr_accessor'. How can I get ruby mode to indent like text mode in this situation? Note that I'd like to be able to select the whole file and hit c-m-\ to get the above indentation in addition to all the other ruby-mode.el indentation rules. 回答1: This hack should work in the majority of cases. (defadvice

Getting Vim to recognize XML

▼魔方 西西 提交于 2019-11-27 13:51:43
问题 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? 回答1: 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

Notepad++ indentation messes up

旧巷老猫 提交于 2019-11-27 11:53:43
I'm coding in Python and I really like Notepad++. However, off late when I use tab to indent, it seems fine in Notepad++, but when I run the program I get an indentation error, and when I check my code in Emacs or something, I find that Notepad++ actually adds more tab spaces than it shows on screen. What is happening? ikottman There is no universal tab size, so I always make sure to replace tabs by spaces (so you know what you see is what you get everywhere else as well) Go to Settings -> "Preferences..." -> Language Menu/Tab Settings and check 'Replace by space' I would suggest going to View

Is there any way to make Visual Studio stop indenting namespaces?

风格不统一 提交于 2019-11-27 11:38:37
问题 Visual Studio keeps trying to indent the code inside namespaces. For example: namespace Foo { void Bar(); void Bar() { } } Now, if I un-indent it manually then it stays that way. But unfortunately if I add something right before void Bar(); - such as a comment - VS will keep trying to indent it. This is so annoying that basically because of this only reason I almost never use namespaces in C++. I can't understand why it tries to indent them (what's the point in indenting 1 or even 5 tabs the

Does Python have a built-in function for unindenting a multiline string?

和自甴很熟 提交于 2019-11-27 11:19:17
问题 Say I have the string s = """ Controller = require 'controller' class foo view: 'baz' class: 'bar' constructor: -> Controller.mix @ """ Every line in the string now has a global 4 space indentation. If this string was declared inside a function, it would have a 8 space global indentation, etc. Does Python have a function for removing the global left indentation of string? I would like that function output to be: Controller = require 'controller' class foo view: 'baz' class: 'bar' constructor:

Python IndentationError: unexpected indent

白昼怎懂夜的黑 提交于 2019-11-27 11:11:38
问题 Here is my code ... I am getting indentation error but i don't know why it occurs. -> # loop while d <= end_date: # print d.strftime("%Y%m%d") fecha = d.strftime("%Y%m%d") # set url url = 'http://www.wpemergencia.omie.es//datosPub/marginalpdbc/marginalpdbc_' + fecha + '.1' # Descargamos fichero response = urllib2.urlopen(url) # Abrimos fichero output = open(fname,'wb') # Escribimos fichero output.write(response.read()) # Cerramos y guardamos fichero output.close() # fecha++ d += delta 回答1:

Python: using 4 spaces for indentation. Why? [closed]

一世执手 提交于 2019-11-27 11:10:51
While coding python I'm using only 2 spaces to indent, sure PEP-8 really recommend to have 4 spaces, but historically for me it's unusual. So, can anyone convince me to use 4 spaces instead of 2? What pros and cons? P.S. And finally, what's easy way to convert all existing codebase from 2 spaces to 4 spaces? P.P.S. PEP-8 Also srictly recommend not using tabs for indention. read here So, to summarize: Pros: Have more space to arrange when wraping string more than 80 lines long. Can copy code from snippets and it just works. Cons: With deeper level of nested statements you have less space for

Emacs cc-mode indentation problem with C++0x enum class

风格不统一 提交于 2019-11-27 10:19:48
问题 Emacs cc-mode does not appear to yet recognize the type-safe enum class introduced in C++0x. The result I get is a double indentation for second, third, etc enums: enum class Color { Blue, Red, Orange, Green }; What I would like is: enum class Color { Blue, Red, Orange, Green }; Can you recommend a good command to add to .emacs which will make cc-mode treat enum class the same way it treats the plain old enum ? 回答1: This is the problem: cc-mode relies somewhat on the assumption that keywords

How do I fix the indentation of an entire file in Vi?

有些话、适合烂在心里 提交于 2019-11-27 09:55:16
In Vim, what is the command to correct the indentation of all the lines? Often times I'll copy and paste code into a remote terminal and have the whole thing messed up. I want to fix this in one fell swoop. Logan Capaldo = , the indent command can take motions. So, gg to get the start of the file, = to indent, G to the end of the file, gg=G . Before pasting into the terminal, try :set paste (and then :set nopaste after you're done). This will turn off the auto-indent, line-wrap, etc. features that are messing up your paste. edit: Also, I should point out that a much better result than =

SQL Statement indentation good practice [closed]

别等时光非礼了梦想. 提交于 2019-11-27 09:38:51
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 6 years ago . What is the accepted practice for indenting SQL statements? For example, consider the following SQL statement: SELECT column1, column2 FROM table1 WHERE column3 IN ( SELECT TOP(1) column4 FROM table2 INNER JOIN table3 ON table2.column1 = table3.column1 ) How should this be