|
|
| About site: Education/Programming/FAQs, Help, and Tutorials - Tabs versus Spaces |
Return to Computers also Computers |
| About site: http://www.jwz.org/doc/tabs-vs-spaces.html |
Title: Education/Programming/FAQs, Help, and Tutorials - Tabs versus Spaces Using tabs in source code: Pro and contra, by Jamie Zawinski. |
|
|
|
|
WarDriving__Decals Wardriver stickers for cars, laptops and folders.
| Global_Information_Infrastructure_Commission An initiative of the Center for Strategic and International Studies dedicated to privatizing or creating cooperative public and private enterprise to increase access to the Internet
| CEI,_Inc_ EnSight post-processor for scientific/engineering data, EnVideo animation viewer, EnLiten 3D animation viewer. Support stereo and VR environments.
| The_Fusebox_Organization Fusebox is a proposed standard way of coding and encapsulating entire ColdFusion applications so that their functionality is available to other applications.
| Concepts2Visions Offers design, graphics, banners, backgrounds, and business logos.
| MKM_Webs,_LLC_ Offers design, maintenance, eCommerce, and hosting services. Located in Wilbraham, M
|
|
| Alexa statistic for http://www.jwz.org/doc/tabs-vs-spaces.html |
Please visit: http://www.jwz.org/doc/tabs-vs-spaces.html
|
| Related sites for http://www.jwz.org/doc/tabs-vs-spaces.html |
| x-kernel Object-based framework to implement network protocols; defines an interface that protocols use to invoke operations on one another (i.e., to send messages to and receive messages from adjacent protoco | | Brahma Online book with information about history, general information, building and maintaining a Beowulf, and parallel computing models. | | MicroServe_Consulting Full service network design consultancy. | | Sepehr_S__T__Co__Ltd_ GateMAN firewalls are TCP stateful inspectors, full application layer and content monitoring system with traffic shaping capabilities. Information available on variours models, frequently asked questi | | Prometheus An Atlanta based Macintosh oriented consulting company specializing in prepress and graphics, Internet publishing, and database design with FileMaker Pro. | | NauSoft_LLC Professional hairstyle imaging software products, plastic surgery software and 3D Hair replacement simulation software. | | SkinGecko_Graphics Dedicated to producing free skins, PSD files, and various graphics to the portal. Also has a small selection of mods. | | Cool_Conversations Desktop Web Reader based on MS-Speech API, coupled with speech recognition. | | Hroly Blogging from the mind of a programmer who would be an author. | | Monkiefarm__A_Genetic_Algorithm_Library This toolset uses an easily extensible genetic graph bipartitioning algorithm to run over an NP hard problem. It encompasses multi-layer perceptron implementations, written in C++. [GPL] | | Spescom_DataVoice Supplies voice and screen communication recording systems for the traditional and IP telephony environment. | | Connecticut\'s_Biometric_Imaging_Project Links, newsletter, projects, and publications. | | X400 A secure X25 or TCP/IP file transfer protocol. | | GTD_systems_and_software_engineering Systems engineering high-tech company leader in space, defence, science, and energy. | | RFC_0888 "STUB" Exterior Gateway Protocol. L. Seamonson, E.C. Rosen. January 1984. | | Inferno_FAQ_for_the_4th_Edition Frequently asked questions about Inferno. (October 6, 2005) | | Pinfeather New media design services based in the Tri-State area; including GIF and Flash animation, 3D, Power Point, programming, CGI, Javascript, audio, logos, and consulting. | | Garraud,_Ben Flash developer with experience in interactive Flash web sites, and illustration. Includes resume to download. Based in Devizes, Wiltshire, England, United Kingdom. | | vBulletin_FAQ A resource for forum owners. Includes news, themes, skins, hacks, styles and optimization for search engines. | | Ideal_Calendar Allows the user to insert an unlimited amount of occasions. The program displays a dialog, and plays a sound on the occasions the user specifies. |
|
This is websites2007.org cache of m/ as retrieved on 2008.10.13 websites2007.org's cache is the snapshot that we took of the page as we crawled the web. The page may have changed since that time.
|
Tabs versus Spaces Tabs versus Spaces:An Eternal Holy War. © 2000 Jamie Zawinski <jwz@jwz.org> The last time the tabs-versus-spaces argument flared up in mypresence, I wrote this. Gasoline for the fire? Maybe. I think a big part of these interminable arguments about tabsis based on people using the same words to mean different things. In the following, I'm trying to avoid espousing my personalreligion here, I just thought it would be good to try and explain thevarious sects. Anyway. People care (vehemently) about a few different things: When reading code, and when they're done writing new code, they care about how many screen columns by which the code tends to indent when a new scope (or sexpr, or whatever) opens. When there is some random file on disk that contains ASCII byte #9, the TAB character, they care about how their software reacts to that byte, display-wise. When writing code, they care about what happens when they press the TAB key on their keyboard. Note that I make a distinction between the TAB character (which is abyte which can occur in a disk file) and the TAB key (which is thatplastic bump on your keyboard, which when hit causes your computer to dosomething.) As to point #1: A lot of people like that distance to be two columns, and a lot of people like that distance to be four columns, and a smaller number of people like to have somewhat more complicated and context- dependent rules than that. As to point #2, the tab character: there is a lot of history here. On defaultly-configured Unix systems, and on ancient dumb terminals and teletypes, the tradition has been for the TAB character to mean ``move to the right until the current column is a multiple of 8.'' (As it happens, this is how Netscape interprets TAB inside <PRE> as well.) This is also the default in the two most popular Unix editors, Emacs and vi. In many Windows and Mac editors, the default interpretation is the same, except that multiples of 4 are used instead of multiples of 8. However, some people configure vi to make TAB be mod-2 instead of mod-4 (see below.) With these three interpretations, the ASCII TAB character is essentially being used as a compression mechanism, to make sequences of SPACE-characters take up less room in the file. Both Emacs and vi are customizable about the number of columns used. Unix terminals and shell-windows are usually customizable away from their default of 8, but sometimes not, and often it's difficult. A third interpretation is for the ASCII TAB character to mean ``indent to the next tab stop,'' where the tab stops are set arbitrarily: they might not necessarily be equally distanced from each other. Most word processors can do this; Emacs can do this. I don't think vi can do this, but I'm not sure. On the Mac, BBedit defaults to 4-column tabs, but the tabstops can be set anywhere. It also has ``entab'' and ``detab'' commands, for converting from spaces to tabs and vice versa (just like Emacs's ``M-x tabify'' and ``M-x untabify''.) As to point #3, the tab key: this is an editor user interface issue. Some editors (like vi) treat TAB as being exactly like X, Y, and Z: when you type it, it gets inserted into the file, end of story. (It then gets displayed on the screen according to point #2.) With editors like this, the interpretation of point #2 is what really matters: since TAB is just a self-inserting character, the way that one changes the semantics of hitting the TAB key on the keyboard is by changing the semantics of the display of the TAB character. Some editors (like Emacs) treat TAB as being a command which means ``indent this line.'' And by indent, it means, ``cause the first non-whitespace character on this line to occur at column N.'' To editors like this, it doesn't matter much what kind of interpretation is assigned to point #2: the TAB character in a file could be interpreted as being mod-2 columns, mod-4 columns, or mod-8 columns. The only thing that matters is that the editor realize which interpretation of the TAB character is being used, so that it knows how to properly put the file characters on the screen. The decisions of how many characters by which an expression should be indented (point #1) and of how those columns should be encoded in the file using the TAB character (point #2) are completely orthogonal. So, the real religious war here is point #1. Points #2 and #3 are technical issues about interoperability. My opinion is that the best way to solve the technical issues is tomandate that the ASCII #9 TAB character never appear in disk files:program your editor to expand TABs to an appropriate number of spacesbefore writing the lines to disk. That simplifies matters greatly,by separating the technical issues of #2 and #3 from the religiousissue of #1. As a data point, my personal setup is the same as the default Emacsconfiguration: the TAB character is interpreted as mod-8 indentation;but my code is indented by mod-2. I prefer this setup, but I don't care deeply about it. I just care that two people editing the same file use the sameinterpretations, and that it's possible to look at a file and know whatinterpretation of the TAB character was used, because otherwise it'sjust impossible to read. In Emacs, to set the mod-N indentation used when you hit the TAB key, do this:(setq c-basic-offset 2) or (setq c-basic-offset 4) To cause the TAB file-character to be interpreted as mod-Nindentation, do this:(setq tab-width 4) or (setq tab-width 8)To cause TAB characters to not be used in the file for compression, andfor only spaces to be used, do this:(setq indent-tabs-mode nil) You can also do this stuff on a per-file basis. The very first line ofa file can contain a comment which contains variable settings. For theXP code in the client, you'll see many files that begin with /* -*- Mode: C; tab-width: 4 -*- */The stuff between -*-, on the very first line of the file, isinterpreted as a list of file-local variable/value pairs. A hairierexample: /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ If you have different groups of people with different customs, thepresence of these kinds of explicit settings are really handy. I believe vi has a mechanism for doing this sort of thing too, but Idon't know how it works. To keep myself honest (that is, to ensure that no tabs ever end upin source files that I am editing) I also do this in my .emacs file: (defun java-mode-untabify () (save-excursion (goto-char (point-min)) (while (re-search-forward "[ \t]+$" nil t) (delete-region (match-beginning 0) (match-end 0))) (goto-char (point-min)) (if (search-forward "\t" nil t) (untabify (1- (point)) (point-max)))) nil) (add-hook 'java-mode-hook '(lambda () (make-local-variable 'write-contents-hooks) (add-hook 'write-contents-hooks 'java-mode-untabify))) That ensures that, even if I happened to insert a literal tab inthe file by hand (or if someone else did when editing this fileearlier), those tabs get expanded to spaces when I save. This assumes that you never use tabs in places where they are actuallysignificant, like in string or character constants, but I never dothat: when it matters that it is a tab, I always use '\t'instead. Here are some details on vi, courtesy of Woody Thrower: Standard vi interprets the tab key literally, but there are popularvi-derived alternatives that are smarter, like vim. To get vim to interpret tabas an ``indent'' command instead of an insert-a-tab command, do this: set softtabstop=2 To set the mod-N indentation used when you hit the tab keyin vim (what Emacs calls c-basic-offset), do this: set shiftwidth=2 To cause the TAB file-character to be displayed as mod-N in vi and vim (what Emacs calls tab-width),do this: set tabstop=4 To cause TAB characters to not be used in the file for compression,and for only spaces to be used (what emacs calls indent-tabs-mode), do this: set expandtab In vi (and vim), you can do this stuff on a per-file basis using``modelines,'' magic comments at the top of the file, similarly to how it works in Emacs: /* ex: set tabstop=8 expandtab: */ So go forth and untabify! |
|
| |
Using | tabs | in | source | code: | Pro | and | contra, | by | Jamie | Zawinski. |
|
http://www.jwz.org/doc/tabs-vs-spaces.html
Tabs versus Spaces 2008 October
dvd rental
dvd
Using tabs in source code: Pro and contra, by Jamie Zawinski.
Rules
|
© 2008 Internet Explorer 5+ or Netscape 6+
|
|
Recommended Sites: 1.
Arts -
Business -
Computers -
Games -
Health -
Home -
Kids and Teens -
News -
Recreation -
Reference -
Regional -
Science -
Shopping -
Society -
Sports -
World
Miss Gallery
- Top Anime Hentai
- DVD rental by mail
- Tax - Mortgages - Remortgaging - Loans - Adverse Credit Remortgage
|