美文网首页
hard-tabs soft-tabs 区别

hard-tabs soft-tabs 区别

作者: 甘言川 | 来源:发表于2016-10-09 20:42 被阅读1729次

转:http://dougneiner.com/post/641596410/tabs-vs-spaces

简单的说:

hard-tabs是硬件tab,就是按一个tab键,soft-tabs是软件tab,通过按4个space键实现。


以下是原文引用:

Tabs vs. Spaces

FRI • MAY 28, 2010490

First off, quick definition: I am referring to the difference between using Tab Characters and Space Characters. Many editors support using the Tab key to insert either a tab character or a certain number of spaces.

Tab Character: Created by using the Tab key, and inserts a single character whose length depends on the settings of the code editor. Its length can vary from editor to editor.

Space Character:Created by using either the Space bar, or the Tab key with Soft Tabs enabled. One character per space, and is a set length. It will always be equal to one character in length.

Soft Tabs:Soft Tabs are created by using the Tab Key, but in reality only insert a set number of Space Characters instead. So a Soft Tab with a setting of 4 will insert Four space characters instead of one tab character when you press the Tab key.

Lets take a quick look at two images. The first shows a PHP function in an editor that has been configured to use Hard Tabs (single character per tab), equal to 4 spaces:

Now, lets look at the same file when opened on a computer/editor that has the preference set that a Hard Tab should display as two characters instead of four.Nothing lines up anymore!:

Here are some reasons for using Spaces (Specifically 2 space indents) instead of Tabs:

Consistentcode viewing on any platform: web, desktop or print

Code takes up less horizontal space, allowing more to be read at one time

It makes code easy to copy and paste for online discussion and sharing since most online viewers render Tab Characters as 4 spaces or more.

One closing thought:This is monospaced code, not MS Word. Variable width tab characters have no place here. Type what you mean, and mean it. Flexibility here only brings confusion.

TextMate:In TextMate I have it set to 2 space tabs, and Soft Tabs on (which tells TM to use spaces instead of real tab characters). This drop down is in the footer in each TextMate window:

相关文章

  • hard-tabs soft-tabs 区别

    转:http://dougneiner.com/post/641596410/tabs-vs-spaces 简单的...

  • 区别

    人和人是有很大区别的,有思想的区别有段位的区别有思考方式的区别有教育的区别身高的区别长相的区别品位的区别衣著打扮的...

  • cocoapods本地私有库

    与公开私有库的区别spec文件区别 podfile区别

  • $arr['0']和$arr[0]的区别

    区别一: 区别二:

  • 指针和引用的区别

    转自 :c++中,引用和指针的区别 自己小结: (1)非空区别 (2)合法性区别 (3)可修改区别 (4)应用区别

  • 2021-07-27

    有区别吗 真的有区别吗 我猜不猜得到有区别吗 有什么区别 我说不说出来有区别吗 有什么区别 你有改变什么吗 有什么...

  • 源码包管理-源码包与RPM包的区别

    大纲 源码包与 RPM 包的区别 源码包安装过程 源码包与RPM包的区别 1. 区别 安装之前的区别:概念上的区别...

  • 读经典的一些思考

    今日读经典,不同人尤其成年人或有些区别与先后。一曰:时间区别,二曰:年龄区别,三曰:境遇区别,四曰:人之区别。 所...

  • iOS 基础知识

    strong & copy 区别 strong & copy 区别 code

  • 单词辨析

    germ与bacteria区别 a few 与 few 区别

网友评论

      本文标题:hard-tabs soft-tabs 区别

      本文链接:https://www.haomeiwen.com/subject/likmyttx.html