用2个空格缩进是否安全? [英] Is it safe to indent with 2 spaces?

查看:175
本文介绍了用2个空格缩进是否安全?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我应该如何缩进代码的一般答案通常是 随您便,但与团队中的每个人都一样,,但是最后一次'已经看到许多项目和平台都依赖 2空间缩进

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.

现在大多数项目都依赖于 2个空格 4个空格 Tabs

Most projects now rely on 2 Spaces, 4 Spaces or Tabs.


  1. 标签

    • WordPress

    • jQuery

    • CakePHP

    • Git

    • Linux内核(似乎不一致) )

  1. tabs
    • WordPress
    • jQuery
    • CakePHP
    • Git
    • Linux Kernel (doesn't seem to be consistent)

  • Django

  • Symfony

  • Stackoverflow

  • Zend Framework

  • Yahoo

  • MacVim

  • Memcached

  • Django
  • Symfony
  • Stackoverflow
  • Zend Framework
  • Yahoo
  • MacVim
  • Memcached

  • Google

  • HTML5 Boilerplate

  • Ruby on Rails

  • Drupal

  • Node.js

  • Github

  • Blueprint-Css

  • Jekyll

  • 选择

  • backbone.js

  • Modernizr

  • Scriptaculous

  • Clojure

  • Facebook(我认为)

  • Google
  • HTML5 Boilerplate
  • Ruby on Rails
  • Drupal
  • Node.js
  • Github
  • Blueprint-Css
  • Jekyll
  • Chosen
  • backbone.js
  • Modernizr
  • Scriptaculous
  • Clojure
  • Facebook (I think)






问题是社区在哪里?是2个空格还是4个空格?


The question is where is the "community" going? 2 Spaces or 4 Spaces?

我的猜测是2个空格,因为它出现在大公司中,并且所有推动标准的项目都在使用它。

My guess is 2 Spaces, since it manifests itself in the big companies and all the standards-pushing projects are using it.

您如何看待当前和未来的情况?适应2个空格的缩进是否明智?

What do you think of the current and future situation? Is it wise to adapt 2 Spaces indentation?

推荐答案

我们在组织中使用TABS进行缩进一个简单的原因。
制表符可以转换为空格,但是空格不能转换为制表符(可靠地)。
一旦掌握了窍门,大多数编辑器便可以设置TAB-WIDTH,以便您可以随意查看缩进的代码。 2,4,6个空格!

We indent with TABS at our organization for one simple reason. Tab's can be converted to spaces, but spaces cannot be converted to tabs (reliably). Once you get the hang of it most editors let you set the TAB-WIDTH, so you can see the code as indented as you would like. 2, 4, 6 spaces!

这篇关于用2个空格缩进是否安全?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆