Jump to content
  • Advertisement
Sign in to follow this  
luasitdown

Format problem

This topic is 4885 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

a lot of source code file look good at vc,but bad in notepad ,write,or other text editor. How could I fix it? Do you often face these problem?

Share this post


Link to post
Share on other sites
Advertisement
What do you mean it looks bad?

Is it that tabs are too wide? VC allows you to set tabspace (default 4), while the windows default is 8, I think. Depending on which version of VC you are running, you can convert tabs to spaces in the Edit->Advanced menu.

Or is there a rectangle character instead of a newline? This would be due to the text format. That is, Windows uses CRLF for newlines, while Linux uses LF only and I believe older macs use CR. You can set the output format in File->Advanced Save Options if you are running VC++.NET.


jfl.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
That's just the tab spacing. I usually go through my code and eliminate all spaces (like in the 2nd example, some are shorter some are longer), and replace them with tabs.

Like jflanglois said, other editors use a different number of spaces for tabs. I would get in the habbit of either always hitting TAB after the type, or just hit space after the type.

You will notice the same thing if you post some code in a message here, if it has spaces and tabs mixed to create formatting that looks correct in the VS editor.

Share this post


Link to post
Share on other sites
The problem is the width of the tabs that the program uses. Some (like notepad) use 8 character wide tab spaces (or something like this), while others use less. For instance, I've set Dev-C++ up to use tab spaces that are 2 characters wide. One solution would be to use spaces instead, since there's a very good chance that the width of a space will always be one.

Share this post


Link to post
Share on other sites
Umm... no, I think the problem here is the fonts being used :)

Serious programmers use a "monospace" font (such as Courier, Monaco, Fixedsys...), where every letter is the same width; that keeps things lined up. Many editing programs will use a "proportional" font by default (such as Arial, Times New Roman...) because they "look better", which is true if you are writing a letter, but horrible for code.

Share this post


Link to post
Share on other sites
Quote:
Original post by Zahlman
Serious programmers use a "monospace" font (such as Courier, Monaco, Fixedsys...), where every letter is the same width; that keeps things lined up.
I just wanted to add that monospace fonts also represent the space character as the same width as every letter, which is critical. Proportional fonts tend to have a very narrow space delineation, which can be up to one-fourth the width of a letter like 'w'! And that's not to mention the havoc that hinting and kerning can cause.

If you're looking at code, always use a monospace font.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!