Jump to content
  • Advertisement
Sign in to follow this  
ascii

indentation

This topic is 4742 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What tool do most of you people use to indent your code? Doing so by hand is a bit tedious, I think.

Share this post


Link to post
Share on other sites
Advertisement
Any decent code editor will, at the very least, automatically tab new lines to the same level as the previous line. That keeps it from being tedious.

Share this post


Link to post
Share on other sites
I don't see how anyone could write good code without indenting as they go. Almost every IDE will happily auto indent lines as you write, so how does it get tedious?

Share this post


Link to post
Share on other sites
Using hard tabs helps a bit too. And many editors support indenting whole blocks of code (try selecting a few lines and pressing tab/shift+tab in MSVC for instance).
If that's too hard then there are utilities available to clean up your code automatically. The classic Unix program indent for instance, I assume a google session would turn up a few C++ equivalents.

Code formatting shouldn't take more than a fraction of the development time however, and is something that you can hopefully learn to do subconsciously while thinking about the problem at hand.

Share this post


Link to post
Share on other sites
Personally, even when planning my programming out on paper I apply my indentation rules to what I'm writing. Then it's just a matter of typing it into the text-editor/IDE and going to town. Considering it takes a mere fraction of a second to reach up and hit a tab, I don't consider it a tedium, considering how many thousands of lines of code itself you may be typing at any given time.

Also, at least with Dev-C++ (which I use), all lines say, within a curly brace are auto-indented unless you reach a new level of scope. What I mean to say is that it auto-indents everything to keep it within scope resolution, making for easy reading and understanding of what is going on where.

Vopisk

Share this post


Link to post
Share on other sites
Hard tabs are outlawed on most modern projects, because they cause more problems than they solve. Stick with a fixed tab size (2, 3 and 4 seem popular), and expand tabs to spaces as you enter them (most editors can do this).

For indenting sloppily copy/pasted code, I just do v-move-== because I'm a VIM guy, but most editors can similarly re-indent the selected code.

Share this post


Link to post
Share on other sites
Quote:
Original post by hplus0603
Hard tabs are outlawed on most modern projects, because they cause more problems than they solve. Stick with a fixed tab size (2, 3 and 4 seem popular), and expand tabs to spaces as you enter them (most editors can do this).

For indenting sloppily copy/pasted code, I just do v-move-== because I'm a VIM guy, but most editors can similarly re-indent the selected code.

we have had the tabs versus spaces arument already

we use hard tabs where I work, with a fixed size for everybody [4 spaces]. A decent editor will treat 4 spaces as a hard tab when you delete it... and will convert to the configured tab when you indent/de-indent

[in python you need to pick one method [hard or soft tabs] and size and be consistent through a file, it is only an issue for display... the code compiles and runs fine]

Share this post


Link to post
Share on other sites
I use hard tabs, mainly because I like the white space. You can always go back later and replace the hard tabs with 2/3/4 spaces if thats the way the people you are working with want it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!