indentation

Is it safe to indent with 2 spaces?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 01:33:57
问题 I know the general answer to "How should I indent my code" is generally "do as you wish but do it the same way as everyone on your team", but in the last time I've seen many projects and platforms relying on a 2-space indentation . I just want to make sure I get the "best bang for my buck" when indenting and make sure it's future-proof. Changing the structure in a project later on is a pretty big problem considering compatibility, etc. Most projects now rely on 2 Spaces , 4 Spaces or Tabs .

How can I make code indentation behave correctly in vbhtml razor files?

送分小仙女□ 提交于 2019-12-09 17:58:55
问题 This is driving me round the bend. I'm a long time VB.NET forms developer, quite new to ASP.NET and completely new to MVC . I'm creating vbhtml pages that use the VB.NET Razor syntax, and I seem to be constantly fighting against the UI which is trying to indent my code incorrectly. Take the following example, based on the template page for a new Razor view: @Code Layout = Nothing End Code <!DOCTYPE html> <html> <head> <title></title> </head> <body> <div> @If True Then @<ul> @For x = 1 To 2

Auto indent doesn't work when using vim coding python

冷暖自知 提交于 2019-12-09 11:15:23
问题 I want to use vim to write python code but there is a problem on auto indention. First I downloaded the latest python.vim from http://www.vim.org/scripts/script.php?script_id=790 and putted it in the correct dir. Then I edited my vimrc. syntax on set nu set tabstop=4 set softtabstop=4 set shiftwidth=4 "set cindent set autoindent set smartindent set expandtab set filetype=python au BufNewFile,BufRead *.py,*.pyw setf python Now I find that keywords like 'for', 'if', 'while' can autoindent

Setting up Vim for Python

做~自己de王妃 提交于 2019-12-08 22:35:51
问题 I really like the Emacs editor for Python because of it's smart tabbing for instance if I have something like this def foo(): if bar: blah [b]eep and I press tab on the cursor (which is on the b of beep), it will not insert a new tab causing a syntax error but it would toggle through the possible levels that beep can be on. Is there anyway of getting this effect on Vim? 回答1: In general, vim is a very powerful regular language editor (macros extend this but we'll ignore that for now). This is

Indenting HTML tags on multiple lines

霸气de小男生 提交于 2019-12-08 20:37:46
问题 I can't find a guideline on how to indent HTML tags on multiple line, and the solution I am currently using doesn't really satisfy me. Imagine we have an extremely long div declaration, such as: <div data-something data-something-else data-is-html="true" class="html-class another-html-class yet-another-html-class a-class-that-makes-this-declaration-extremely-long" id="just-a-regular-id"> In order to avoid scrolling horizontally when I find these huge lines, I usually indent them in the

How can I make vim align the ternary ?: operator nicely?

半城伤御伤魂 提交于 2019-12-08 16:14:24
问题 I like to write code using the ternary ?: operator like this: std::string result = input.empty() ? createNewItem() : processInput( input ); How can I configure vim so that when pressing Return after having typed createNewItem() indents the next line so that the cursor is in the same column as the last ? so that I can just continue typing : processInput( input ); ? I tried looking at the cinoptions-values setting but I didn't see anything relevant. 回答1: You can achieve this at least partially

Indenting issue after access specifiers in Visual Studio Express [duplicate]

不打扰是莪最后的温柔 提交于 2019-12-08 15:48:35
问题 This question already has answers here : C++ access modifier auto indentation in Visual Studio 2010 slowly driving me crazy - can it be changed? (2 answers) Closed 3 years ago . I am using Visual Studio Express 2013 After I use an access specifier, I want Visual Studio to automatically indent my members another 4 spaces further than my access specifier; but instead, it keeps the members in line with the access specifier. Is there a way to fix this? Example: This is what is does: class MyClass

XmlWriter.WriteRaw indentation

[亡魂溺海] 提交于 2019-12-08 15:10:27
I have a similar question like XML indenting when injecting an XML string into an XmlWriter . I also use XmlWriter.WriteRaw to output an XML fragment into an xml node. This document fragment does not follow the idention which would be nice. The answer given on the post above does not work for XML fragments. Well, I can read the fragment with the XmlReader , but WriteNode does not work with document fragments (see http://msdn.microsoft.com/en-us/library/1wd6aw1b.aspx ). Any hints on how to cheat to get proper indentation? Thanks for any hints You could build a valid Xml-Document in memory

Chained methods and continuation indent in Intellij

老子叫甜甜 提交于 2019-12-08 15:00:35
问题 I've never figured out how to make Intellij handle continuation indent for chained methods properly, and apparently today is the day it's annoyed me enough to consult you lovely people. What I want is this: makeAThing( "with", "params" ) .setProperty("with some more params") .start(); What I get is this: makeAThing( "with", "params" ) .setProperty("with some more params") .start(); I get this in Java, Groovy, JavaScript and a bunch of other places. How can I persuade Intellij not to add

Indent Expected?

久未见 提交于 2019-12-08 14:13:42
问题 I'm sort of new to python and working on a small text adventure it's been going well until now I'm currently implementing a sword system where if you have a certain size sword you can slay certain size monsters. I'm trying to code another monster encounter and I have coded the sword stuff but I'm trying to finish it off with an else to the if...elif...elif statement and even though I have it in the right indentation it still says indent expected I don't know what to do here's the code: print