![]() ![]() Easy to differentiate between code & text/content.Start ( ) & end ( ) are at same level, so it's easy to see that you've closed code & also see where code starts & ends.Problem: Because everything is at left margin, hard to differentiate code & text/content Ullamco laboris nisi ut aliquip ex ea commodo consequat. Here are some examples of how WebSanity likes to indent our code. Note: Again with the multiple levels of indenting-but it should be obvious how much it helps reading that code! See how easy it is to tell what's a child of what? Note: Notice how text/content is indented inside, and then is indented inside. Note: We don't indent & other headers because they're short, but if you want to indent, that would be fine. Note: Again, we don't indent & most other items inside because they're short. Note: We don't indent because most of the time the contents are short, because we're more concerned about the &, & because it can really lengthen the overall code. That said, if you want to indent, feel free. So why aren't & indented? A couple of reasons: You'd think that & would be indented inside -after all, they're children of, so shouldn't they be indented? What about the basic structure of a webpage? Ut enim ad minim veniam, quisĪdipisicing elit, sed do eiusmod tempor incididunt Sed do eiusmod tempor incididunt ut labore et dolore Lorem ipsum dolor sit amet, consectetur adipisicing elit,.You know that & are the children of in fact, they're always the only children of, so there's no need to remind yourself of this via nesting.You save yourself one level on indentation when you start nesting HTML inside HTML inside HTML inside HTML, this can add up.Your text editor should make it easy to indent your code You could press tab or the space bar every single time you want to indent your code, but you shouldn't have to do that. Fortunately, good text editors help you out when it comes to indenting. Auto-indentīBEdit, for instance, has a setting in its Preferences for "Auto-indent", which it defines as follows: "When this option is selected, pressing the Return key in new windows automatically inserts spaces or tabs to indent the new line to the same level as the previous line."Īny good text editor should have a setting like this somewhere. The trick is finding it in the editor's Preferences or Options. Should you use spaces or tabs for indenting? A debate has raged on this topic for decades, with different developers insisting that theirs is the right choice. WebSanity uses spaces, for various reasons, so that is the right choice, clearly. Your text editor should let you choose what gets inserted when you press the TAB key: a tab or spaces. Notepad++: Preferences > Language Menu/Tab Settings > Replace by space.Komodo Edit: Options/Preferences > Editor > Indentation > Prefer Tab characters over spaces.BBEdit: Preferences > Editor Defaults > Auto-expand tabs.ĭifferent text editors call that setting different things. Note: If anyone knows of any others that I should add, let me know. The next question is, how many spaces get inserted when you press TAB? Basically, people either choose 2, 4, or 8 spaces. Here's a link to CotEditor's open source repository on GitHub.With 2, you can see the indentation, but lots of nesting doesn't push your code out to ridiculous lengths, as you can see in the following: In WebSanity's opinion, 8 is far too many, 4 is acceptable but a bit too large, & 2 is just right. ![]() "Excellent support for Japanese encoding" is the top reason why over 2 developers like CotEditor, while over 94 developers mention "Syntax for all languages that i use" as the leading cause for choosing Notepad++.ĬotEditor is an open source tool with 2.77K GitHub stars and 252 GitHub forks.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |