indentation

Indenting #defines

北城以北 提交于 2019-11-26 12:38:53
问题 I know that #define s, etc. are normally never indented. Why? I\'m working in some code at the moment which has a horrible mixture of #define s, #ifdef s, #else s, #endif s, etc. All these often mixed in with normal C code. The non-indenting of the #define s makes them hard to read. And the mixture of indented code with non-indented #define s is a nightmare. What is the benefit of not indenting #define s? Does it make me a bad person if I indent them? Isn\'t this much nicer? #ifdef SDCC #if

How to indent multiple levels of select optgroup with CSS?

匆匆过客 提交于 2019-11-26 12:28:32
问题 Just trying to indent optgroup blocks by nesting depth really, I\'ve tried a general margin-left rule, nested elements then trying to apply the same rule, tried padding-left ... is indenting like this possible? It seems elementary :P In the example below, the optgroup labelled \'client2_a\' should be indented more than the others, because it is nested inside \'client2\'. http://jsfiddle.net/Tb5Rc/5/ 回答1: 8/29/2016 Edit The original answer below is no longer functional in modern browsers. For

Is it possible to display Indentation guides in Vim?

风流意气都作罢 提交于 2019-11-26 11:55:38
问题 I\'m a longtime Vim user (3 or 4 years) who has recently started dealing with some deeply nested code. This code is indented with spaces, not tabs. I would like some clean and non-distracting indication of indentation to help with keeping track of which block of code I\'m in when I\'m looking at something many levels deep. :set list Only displays tab and endline characters. I have found one plug-in (can\'t seem to dig it up at the moment) that will highlight each indentation level in

Custom Brace formatting with Resharper

随声附和 提交于 2019-11-26 11:53:50
问题 I\'m using Resharper 4.5 and I need custom formatting of braces when writing an array or object initializer. Resharper supports some styles: Gnu Style: int[] array = new int[] { 1, 2, 3 } but I need: int[] array = new int[] { 1, 2, 3 } Is there any way to customize this templates? 回答1: You can customize ReSharper to do just that, you'll need to do the following (All in ReSharper -> Options -> C# -> Formatting Style ): In Braces Layout , set Array and object initializer to At Next line (BSD

What is the proper way to format a multi-line dict in Python?

南楼画角 提交于 2019-11-26 11:50:39
问题 In Python, I want to write a multi-line dict in my code. There are a couple of ways one could format it. Here are a few that I could think of: mydict = { \"key1\": 1, \"key2\": 2, \"key3\": 3, } mydict = { \"key1\": 1, \"key2\": 2, \"key3\": 3, } mydict = { \"key1\": 1, \"key2\": 2, \"key3\": 3, } I know that any of the above is syntactically correct, but I assume that there is one preferred indentation and line-break style for Python dicts. What is it? Note: This is not an issue of syntax.

Inconsistent use of tabs and spaces in indentation

给你一囗甜甜゛ 提交于 2019-11-26 11:29:56
问题 def contains_sequence(dna1, dna2): \'\'\' (str, str) -> bool Return True if and only if DNA sequence dna2 occurs in the DNA sequence dna1. >>> contains_sequence(\'ATCGGC\', \'GG\') True >>> contains_sequence(\'ATCGGC\', \'GT\') False \'\'\' b=False len2=len(dna2) i=0 for j in dna1: temp=dna1[i:i+len2] if temp == dna2: b=True i=i+1 return b I am new to Python. The program pasted above gives me an error \"Inconsistent use of tabs and spaces in indentation\" at line \"if temp == dna2:\"

Tabs versus spaces in Python programming

China☆狼群 提交于 2019-11-26 11:29:48
I have always used tabs for indentation when I do Python programming. But then I came across a question here on SO where someone pointed out that most Python programmers use spaces instead of tabs to minimize editor-to-editor mistakes. How does that make a difference? Are there other reasons why one would use spaces instead of tabs for Python? Or is it simply not true? Should I switch my editor to insert spaces instead of tabs right away or keep on going like I used to? Alexander Kojevnikov Because PEP-8 tells us to use spaces. yota Tired of chasing after indentation typos ( 8 spaces ? no, 7

How do I reformat HTML code using Sublime Text 2?

心已入冬 提交于 2019-11-26 11:27:10
I've got some poorly-formatted HTML code that I'd like to reformat. Is there a command that will automatically reformat HTML code in Sublime Text 2 so it looks better and is easier to read? peter You don't need any plugins to do this. Just select all lines ( Ctrl A ) and then from the menu select Edit → Line → Reindent. This will work if your file is saved with an extension that contains HTML like .html or .php . If you do this often, you may find this key mapping useful: { "keys": ["ctrl+shift+r"], "command": "reindent" , "args": { "single_line": false } } If your file is not saved (e.g. you

How to properly indent PHP/HTML mixed code? [closed]

余生颓废 提交于 2019-11-26 10:31:21
When mixing PHP and HTML, what is the proper indentation style to use? Do I indent so that the outputted HTML has correct indentation, or so that the PHP/HTML mix looks properly formatted (and is thus easier to read)? For example, say I have a foreach loop outputting table rows. Which one below is correct? PHP/HTML mix looks correct: <table> <?php foreach ($rows as $row): ?> <tr> <?php if ($row->foo()): ?> <?php echo $row ?> <?php else: ?> Something else <?php endif ?> </tr> <?php endforeach ?> </table> Outputted HTML looks correct: <table> <?php foreach ($rows as $row): ?> <tr> <?php if ($row

Correct indentation of HTML and PHP using Vim

[亡魂溺海] 提交于 2019-11-26 10:22:05
问题 I\'ve been using Vim for a while, and I can\'t get proper HTML indentation working in PHP files. For example, what I want is for each child to be indented one tab more than it\'s parent, as shown below. <?php if(isset($sports)) { //Do something ?> <div> <label>Uniform Size</label> <ul> <li class=\"left\"><label for=\"s\" class=\"small\">S</label><input type=\"radio\" name=\"size[]\" value=\"S\" id=\"s\" class=\"radio\" /></li> <li class=\"left\"><label for=\"m\" class=\"small\">M</label>