Thread: Is there any way for a program to find out how many spaces...?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Programming Ninja In-T...
    Join Date
    May 2009
    Posts
    827
    Quote Originally Posted by Florian View Post
    I believe tab size is dependent on the file editor with which you are reading the file. There is no system wide tab size.
    Well, I thought the same thing, but then I found out that the editor I'm viewing the file in (gedit) has 8 spaces for one tab created in the editor, but the tabs that I copied/pasted into the file (along with the rest of the content), and saved, represents a different number of spaces. So it seems that somehow whatever editor or program that writes the tab characters effects how many spaces they will represent across all editors that view the same file. Or else, gedit would be showing all tabs as 8 spaces, wouldn't it?
    I'm an alien from another world. Planet Earth is only my vacation home, and I'm not liking it.

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by Programmer_P View Post
    So it seems that somehow whatever editor or program that writes the tab characters effects how many spaces they will represent across all editors that view the same file. Or else, gedit would be showing all tabs as 8 spaces, wouldn't it?
    Are you sure you have copied the tab character?
    Or the "source" editor replaced the tab character with several spaces before putting the block into the copy-buffer?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Programming Ninja In-T...
    Join Date
    May 2009
    Posts
    827
    Quote Originally Posted by vart View Post
    Are you sure you have copied the tab character?
    Or the "source" editor replaced the tab character with several spaces before putting the block into the copy-buffer?
    Yes, I am sure that it is the tab character, because when I put the cursor on a given line with the tab characters, I used the right arrow key to move the cursor horizontally across the text, and when it gets to the tab character that is there, it *jumps* across several spaces, instead of just going one space, like it does for space characters. That is how I know it is a tab character. That also with the fact that my program's output file, which is a copy of the input file with said tabs replaced with spaces, doesn't do that on the same lines as the original file, since the tab characters were replaced with several spaces.
    I'm an alien from another world. Planet Earth is only my vacation home, and I'm not liking it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 09-02-2011, 04:57 PM
  2. Program does not printf after spaces.
    By team23 in forum C Programming
    Replies: 5
    Last Post: 09-18-2010, 03:46 PM
  3. Replies: 7
    Last Post: 10-03-2009, 10:58 PM
  4. Replies: 4
    Last Post: 12-01-2007, 04:10 PM
  5. Can't find spaces
    By Drakon in forum C++ Programming
    Replies: 14
    Last Post: 04-07-2004, 10:02 AM