|
OriginalGriff wrote: Most editors can, but they tend to default to "use tabs" to save file space. To save file space???
You (or rather, those you refer to) can't be serious. In year 2023, you do not seriously use a tab character to save three (3) bytes of space! My home PC has two 16 TB disks, one 8 TB and one 1 TB M.2 main disk - that is almost 14 trillion (English - that is 'billion' in many other countries) times the space a tab character will save.
My home PC certainly has got more disk space than most home PCs. Not only have I been using digital video cameras since they came to the market - I imported one from abroad before they were introduced in Norway - but I also have had all my old video, Super-8 and old 8mm digitized. Yet, disk capacities are generally stated in terabytes nowadays.
If you need to save 3 bytes of space here, 3 bytes there, then I guess you also need to rule out file systems that allocate disk blocks of 4 Ki size; 512 bytes would be the maximum acceptable. Maybe you should go down to the old floppy disk standard of 128 byte sectors ... Even 512 bytes rules out NTFS, but I guess you could use some FAT variant. I am not familiar with all 42 Linux file systems, but I'd be surprised if not at least a few of them can be configured for 128 bytes allocation unit. If you worry about a waste of 3 bytes for a source file indent, you will probably want to use 128 bytes units.
|
|
|
|
|
OriginalGriff wrote: "use tabs" to save file space
I'm quite certain that isn't the reasoning. I think some TABophiles use TABs to save keystrokes.
I, of course, use two SPACEs per TAB and otherwise a whole ing load of whitespace, vertical space in particular. I am not interested in "saving space" or "saving keystrokes" I need space so I can read the stuff.
The simple IDE I developed for myself defaults to TABs because there is no reasonable number of SPACEs to use as a default instead. But what can save file space is that it right-trims SPACEs from lines when it saves a file -- that eliminates a lot more characters from saved files than using TABs.
|
|
|
|
|
The reason I use tabs is Shift+Arrow = Highlight - Tab/Shift-Tab = indent/deindent the block of text.
I use this so often when I code that I could scarcely be productive without it.
To err is human. Fortune favors the monsters.
|
|
|
|
|
honey the codewitch wrote: Tab/Shift-Tab = indent/deindent the block of text
Yes, using the TAB key, but it actually inserts/removes the necessary number of SPACEs rather than TABs.
I don't see that TAB characters makes a difference in doing that.
|
|
|
|
|
Oh, I think my editor uses tabs. So I just use them too. It would be weird anyway for me switching between Tab and spacebar.
In the end i always "Format Document" and I've got the process for that tailored more or less to my liking so it's easy and it works for me.
To err is human. Fortune favors the monsters.
|
|
|
|
|
I'm not talking about using the spacebar to indent code. I don't think the issue is about what key is pressed, but about what characters are produced and stored.
Back when using a VT we had to indent by using the spacebar. But with modern(ish) IDEs we use the TAB key, and have it insert either SPACEs or TABs as configured -- the result looks the same, but it isn't.
I don't recall what Turbo Pascal and C/C++ did with TABs.
When I use Notepad, I still have to use the spacebar to indent because it uses eight-character-wide TAB-stops, but I don't use that for code.
|
|
|
|
|
Ah, I getcha. Sorry. Yeah, I think my editor inserts 4 spaces when I hit tab.
To err is human. Fortune favors the monsters.
|
|
|
|
|
I used to do four, but I've cut down to two. Which is bizarre considering the tiny (8 pt) font I use for code.
|
|
|
|
|
No, it’s logical: four spaces would indent too much in relation to font size.
Full disclosure: I also use two spaces and a tiny font
Mircea
|
|
|
|
|
I have the opposite opinion, I think the indent should remain constant (maybe about a 1/4 or a 1/2 inch) regardless of font size, so a tab-stop would use fewer character-places with a larger font and more with a smaller one.
But I know of no IDE which uses absolute tab-stops -- I wouldn't willingly code in a word processor.
|
|
|
|
|
Let’s agree to disagree
There is a reason however why letters have a certain height to width ratio. Also paragraph indenting, in books that use it, is proportional to font size. Your artistic eye might know better than your logical brain
Mircea
|
|
|
|
|
Certainly, and a lot of this still stems from VT screens and such with only one or two character sizes.
On a VT340 or such I used the 132 character-per-line setting because I didn't like to 80 character-per-line limit.
I'm not real concerned with literature type setting.
Don't get me started on illuminated letters at the start of every block... 
|
|
|
|
|
Mircea Neacsu wrote: There is a reason however why letters have a certain height to width ratio. Also paragraph indenting, in books that use it, is proportional to font siz
True.
However English text is the not the same as programming. I read English very fast and often deliberating skip parts. Certainly I am generally oblivious to periods.
But ignoring a period in programming would be a bad idea.
In the editor I use the typeface is specifically not proportional. I have tried it and found it to be a very bad idea. In English text the layout of the text seldom has meaning. In programming the layout does convey information such as easily seeing blocks.
|
|
|
|
|
I didn’t say the text of a program is the same as the text of a novel. What I do say however is that people writing programs could use a bit from the centuries of experience of typographers.
It might be one of my (many) obsessions, but being somewhat dyslexic, I pay a lot of attention to things like font typeface, tab sizes page layout and such. When things go well, my programs are a thing of beauty in content and form. That happens rarely 🤪
Mircea
|
|
|
|
|
Mircea Neacsu wrote: I didn’t say the text of a program is the same as the text of a novel
The thread is about programming but you then said the following
"in books that use it, is proportional to font size"
The way I read that post suggested that there is an equivalence. As I read it. I saw nothing in the post to which you responded which would have suggested they were referring to English.
|
|
|
|
|
Tab spaces should be in half-inches or centimeters, depending where you live. Not characters.
Nothing succeeds like a budgie without teeth.
To err is human, to arr is pirate.
|
|
|
|
|
I agree, but only as an ideal as I know no IDE which can do that.
|
|
|
|
|
I do not understand why anyone uses spaces tbh. I also set my tab spacing to 2, but most of the legacy code I work on - and even some of the newer stuff added to that legacy code - uses spaces, and are thus untidy along the left margin and often not collapsible. Use tabs, for the love of pretty code, and for that matter, used blank lines between logical blocks. And concise comments.
|
|
|
|
|
I see no reason it wouldn't be collapsible. What IDE can't collapse it?
How does your code look if you open it in another IDE/editor? Open it in Notepad for instance.
|
|
|
|
|
a slight exaggeration and significant simplification:
some code
some more code that should be on the same tab as the above, but here's a loop
{
code that loops or whatever
// a comment
}
// a comment
code loop
{
code
}
|
|
|
|
|
PIEBALDconsult wrote: I think some TABophiles use TABs to save keystrokes.
I use spacing to provide formatting.
Tabs in a file, not spaces allows one to skip backwards with fewer keystrokes. Never seen that happen with pseudo spaces (tabbing but with space replacement.)
Since I am also very much a touch typist auto indenting tends to be a hinderance since it tends to break my train of thought. While tabbing (space replacement or not) is fewer keystrokes to get to where I actually want to be without it.
|
|
|
|
|
jschell wrote: skip backwards with fewer keystrokes
Yes, I can see that, but it isn't that big of a deal for me, in fact I think I frequently use the mouse to do that, which is worse.
Also, when using two SPACEs per indent it's less of a burden than with four.
jschell wrote: a touch typist
I definitely am not, but coding is like writing literature, so it's OK.
jschell wrote: auto indenting tends to be a hinderance
Unsure what you are referring to. If you mean having a new line auto-indented to the same level as the previous when you hit RETURN, I like that. With my coding format style, I have a lot of indent levels, so that saves me type.
jschell wrote: it tends to break my train of thought
There are still things Visual Studio does which I don't like and I seem to have no control over them, and I occasionally have to UNDO (Ctrl-Z) an auto-formatting change it made.
It's part of why I wrote my own simple IDE which does only what I want it to.
|
|
|
|
|
Just add braces. For the "purists" make them optional. I have set a new project NPP policy: No Python Period. Cannot find a compelling reason to introduce chaos just to be trendy.
|
|
|
|
|
Any programming language that depends on formatting is fundamentally flawed by design!
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
- G.K. Chesterton
|
|
|
|
|
I use two SPACEs per TAB. The simple IDE I wrote can do it, even were I ever to use it for Python.
On the other hand, a TAB-stop should be a certain width (e.g. a half inch), regardless of font and display medium, not measured in "character positions". If we could have that, then maybe TABs would make sense.
|
|
|
|