indentation

Is it safe to indent with 2 spaces?

廉价感情. 提交于 2019-12-05 01:40:36
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 . Projects and their indentation: tabs WordPress jQuery CakePHP Git Linux Kernel (doesn't seem to be

Emacs custom indentation

旧街凉风 提交于 2019-12-05 01:21:41
My team uses a special type of file for configuration, and I would like to auto-indent (block indent) the file using emacs. I would like to increase the indentation by a tab size for an opening parenthesis - { or [, and decrease by a tab size for a closing parenthesis - } or ] . For example, files = { file1 = first_file.txt file2 = second_file.txt rules = { skip_header = 1 fast_process = 1 } } C-style indentation doesn't work since a line doesn't end with semi-colon. I have studied about emacs indentation for half a day today, but still doesn't know how to do this. Derive a new mode from text

How do I define indents in vim based on curly braces?

混江龙づ霸主 提交于 2019-12-05 00:42:36
问题 I use https://github.com/cakebaker/scss-syntax.vim for syntax highlighting SCSS (or SASS ) files on vim, which works very well for syntax highlighting. However, the plugin does not come with an indent file and am having trouble writing one. I would like to set the indent to look like this: However, if i do gg=G , I get: I suspect that it does not understand nested indent based on braces. I tried all the different combinations of set cindent set nocindent set autoindent set smartindent and

Annoying vim (un)indent rules

一个人想着一个人 提交于 2019-12-05 00:30:17
When editing PHP code (I'm not sure if it's specific to that language) and I create a new line in the middle of comma-separated lists that span multiple lines, the indent rules always unindent the line I'm leaving. Here's a video of it. This happens in arrays, function argument lists, etc. Is there anything I can do to stop this from happening, or any quicker methods of fixing the error than moving up, re-indenting it, moving down, re-indenting (since it gets cleared when you leave the line), and continuing? .vimrc Try :set indentexpr="" and see if that helps. See :help filetype-indent-off for

In C#, how do I convert a XmlNode to string, with indentation? (Without looping)

ぐ巨炮叔叔 提交于 2019-12-05 00:00:49
This has got to be such a simple question but I just can't get the answer. I have an XmlNode and all I want to do is output this node, as a string, with indentations (tabs or spaces) intact to provide better readability. So far I tried XmlWriter, XmlTextWriter, XmlDocument, XmlReader. I tried the PreserveWhitespace in XmlDocument but I couldn't get the XmlDocument to output my node. I tried the Formatting = Formatting.Indented property in XmlTextWriter but I couldn't figure out how to output the contents to string. To output the XmlNode as string WITHOUT indentation is easy. I just do XmlNode

Why is vim indenting my Perl code incorrectly?

拈花ヽ惹草 提交于 2019-12-04 23:30:39
问题 I have a subroutine in Perl that should be indented like this: sub GetFiles { my $pwd = shift; my @input = @_; my @returned; my @DirectoryContent = &GetContentInformation(@input); foreach (@DirectoryContent) { my %current = %{$_}; if ($current{'info'} =~ /<DIR>/) { my $RecurseDir = &GetRecurseDir($pwd, \%current); push(@returned, &GetFiles($RecurseDir, &GetDirectoryContents($RecurseDir))); } else { # clean up the data my $size = $current{'info'}; # filesize will be in number of bytes # remove

How do you make Git ignore spaces and tabs?

纵然是瞬间 提交于 2019-12-04 16:55:59
问题 I have a small scripting project that consists of five different source files in one directory called "Droid XX-XX-XX". Each time I created a new backup copy of the source directory, I put the date in the X's. So there are about 15 different versions from different dates. I want to add each of these to my bare new Git repository starting from the earliest. However I have run into several problems. One problem is that some of the files use tabs for indentation, while others use spaces -- but

Indentation in VS Code

有些话、适合烂在心里 提交于 2019-12-04 15:51:49
问题 I'm a long time Emacs user. I've been trying out VS Code and i like it so far. One thing i love about Emacs is that it always indents the code correctly when i press tab. I've looked but i can't seem to get that behavior in VS Code. I've tried looking in the settings and searching for an extension but have had no luck. Can anyone help me on this please? Is there an extension i can/have to install to get it to do what i want? I code mostly in PHP, HTML, CSS and Javascript. Thanks in advance.

Java XML Output - proper indenting for child items

别说谁变了你拦得住时间么 提交于 2019-12-04 14:24:10
问题 I'd like to serialize some simple data model into xml, I've been using the standard java.org.w3c -related code (see below), the indentation is better than no "OutputKeys.INDENT", yet there is one little thing that remains - proper indentation for child elements. I know that this has been asked before on stackoverflow , yet that configuration did not work for me, this is the code I'm using : DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder =

eclipse xml editor indent using spaces

ε祈祈猫儿з 提交于 2019-12-04 10:59:25
问题 My eclipse version is Mars Release (4.5.0).Preferences->XML->XML Files->Editor,I can not set the value of Indentation size. The "+" and "-" can not be clicked . I can not input value yet! 回答1: Had the same problem, I found the following workaround: open with a text editor this file in your workspace folder: .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.xml.core.prefs change or add the following line ("4" is just an example): indentationSize=4 (Re)start Eclipse 回答2: