64Gbyte flash memory - hot stuff, unfortunately

I took a look at emacs a while ago. However it was just a bit too foreign to wrap my head around. I think tab handling was the straw that broke the camel's back.

Dunno about a Windoze version of vi, but I'm sure something exists. However, if I call up a file that has CRLF line endings in vi on my Linux box, each line has a blue "^M" at the end; the CRLF endings are preserved.

--
/~\  cgibbs@kltpzyxm.invalid (Charlie Gibbs) 
\ /  I'm really at ac.dekanfrus if you read it the right way. 
 Click to see the full signature
Reply to
Charlie Gibbs
Loading thread data ...

What does it do with tabs? Codewright could be pretty weird. The choices were to replace tabs with spaces (which means deleting them is a PITA) or using tabs (which means putting them in lots of times when you are trying not to). Didn't seem to have a middle ground of inserting tabs when you hit the tab key one. But maybe I missed an option or two.

What did it do on your Linux box when you opened a DOS file and typed some extra lines? Did the new lines have the CR inserted too?

--

Rick C
Reply to
rickman

That's the problem I was having. I'm stuck in a nasty middle ground where I want to indent my C code by multiples of 4 spaces, and many programs (e.g. cat) assume a tab every 8 spaces. So I wind up typing 4 spaces for the first level of indentation, tab for the second level, tab plus four spaces for the third level, two tabs for the fourth, etc. I'm the first to admit that it's ugly - especially when moving a block of code and changing its indentation. But the only alternative is to do away with tabs altogether, and as you say it's a PITA. I can't remember just what emacs did or how much work I'd have to do to make it work, but it was almost as ugly, and not too compatible with cat and friends.

(I couldn't remember so I did a quick test just now.) No, they went in with LF only, just like a normal *n*x line. I could delete the ^M character at the end of existing lines, but I couldn't think of a quick way to put one back. I'm sure some vi guru will have a magic solution...

--
/~\  cgibbs@kltpzyxm.invalid (Charlie Gibbs) 
\ /  I'm really at ac.dekanfrus if you read it the right way. 
 Click to see the full signature
Reply to
Charlie Gibbs

CW didn't deal with that. I would set the tab to 4 spaces. I find many editing programs have the ability to configure the tab size. So that wasn't the problem. When you hit return CW would auto indent to match the previous line and if that meant tabs were needed, you got tabs. Backspace a couple of chars and you suddenly backspace by four. Not every file or every line in the file was aligned to tabstops. Likewise, inserting spaces had to be done at the right point or it was just adding spaces in front of the tab. I would have liked it to have inserted spaces, but allow me to backspace by tabstops somehow when needed.

That was one of the nice things about CW, it recognized which flavor of file you had and would conform to that convention for that file.

--

Rick C
Reply to
rickman

Emacs understands the difference between a tab character and an indentation amount. (Or maybe I should say emacs can be made to understand the difference between those two concepts). You just need to configure it for what you want. (You may find that easy, maybe not.)

When moving a block of code around, it is easy to re-indent it. There is a function in cc-mode called "c-indent-defun". I have ^C^Q bound to that, and so any time the indentation gets messed up, it is very quick to re-indent the whole function.

You can set up emacs so that the tab key puts in the right amount of indentation for the current line. With tab chars being 8 spaces wide, it can either be told to use only spaces for indentation or it can be told to use the appropriate number of (8-wide) tabs followed by (e.g.)

4 spaces.

Cheers.

Jim

Reply to
Jim Diamond

So it _can_ be done. I'll have to take another look at it in my copious free time. (Hah!)

One solution I find unacceptable is to use one tab character per level; if you tell your editor of choice that a tab is 4 characters, your code might look great in that editor, but it'll still look like hell everywhere else.

--
/~\  cgibbs@kltpzyxm.invalid (Charlie Gibbs) 
\ /  I'm really at ac.dekanfrus if you read it the right way. 
 Click to see the full signature
Reply to
Charlie Gibbs

*Horrible* (unless your editor is actually converting the tabs to spaces which some do) a tab character is an instruction to jump to the next tab stop (wherever that may be) so assuming any fixed number of spaces is wrong. Indentation is best done using either spaces or tabs but never mixed.

I prefer to use tabs for indentation and only for indentation (alignment within an indentation block uses spaces) because I can display the code with any tab settings and it aligns perfectly, however when its not my own code and others will be editing it then spaces are less likely to get screwed up and that's what goes into the coding standards, usually enforced by a checkin gate.

--
Steve O'Hara-Smith                          |   Directable Mirror Arrays 
C:>WIN                                      | A better way to focus the sun 
 Click to see the full signature
Reply to
Ahem A Rivet's Shot

Neither. I was "forced" to learn a bit of vi, as at the command prompt there's little available after a failed boot of a pi. I use Geany (if on a linux GUI) or notepad2 on XP these days.

--
Bah, and indeed, Humbug
Reply to
Kerr Mudd-John

Of course there is the time when a co worker decides to compact all the source files by reducing 8 spaces to a tab...including the spaces in the carefully formatted strings for the help and information screen display of the embedded product...

--
There is something fascinating about science. One gets such wholesale  
returns of conjecture out of such a trifling investment of fact. 
 Click to see the full signature
Reply to
The Natural Philosopher

Are you seriously using an editor for actual work, that does not even have have a configurable tab length?

My editor has that one configurable too on saving the file.

--




/ \  Mail | -- No unannounced, large, binary attachments, please! --
Reply to
Axel Berger

Theres a wonderful console based 'Look I look just like wordstar' editor for Linux somewhere...Joes Own Editor, or JOE IIRC.

Frankly I may switch to that for book writing...

--
No Apple devices were knowingly used in the preparation of this post.
Reply to
The Natural Philosopher

... and they bounce off the checkin gate which stops it bothering anyone else.

--
Steve O'Hara-Smith                          |   Directable Mirror Arrays 
C:>WIN                                      | A better way to focus the sun 
 Click to see the full signature
Reply to
Ahem A Rivet's Shot

this is nothing to do with cat as shuch it is the default unix tab specification it can be changed in many ways using the tabs command

for example

tabs +4 will set your tabs to every 4th column.

--
Arnold's Addendum: 
	Anything not fitting into these categories causes cancer in rats.
Reply to
alister

IIRC nano is installed as standard on a PI it is far simpler for basic editing that either of the two behemoths that are treated as rights of passage by some UNIX gurus. I am reminded of two quotes:

1 Vi is a text editor with two modes mode 1 beeps continuously & mode 2 corrupts files. 2 EMACS has everything needed to make a great operating system except a good text editor.

  • 1 for Geany - even when I am forced to use Windoze
--
Brief History Of Linux (#11) 
Birth of Gates and the Anti-Gates  
 Click to see the full signature
Reply to
alister

Provided the terminal (usually virtual these days) supports setting tabs otherwise you just get this:

$ tabs +4 tabs: terminal cannot set tabs

--
Steve O'Hara-Smith                          |   Directable Mirror Arrays 
C:>WIN                                      | A better way to focus the sun 
 Click to see the full signature
Reply to
Ahem A Rivet's Shot

This would work fine on my own Linux box - at least until I forget to reset it before looking at someone else's files tabbed every 8 characters. And it wouldn't help if I want to look at the source code on a Windows box.

It seems that tab characters in source files are just not a good thing.

--
/~\  cgibbs@kltpzyxm.invalid (Charlie Gibbs) 
\ /  I'm really at ac.dekanfrus if you read it the right way. 
 Click to see the full signature
Reply to
Charlie Gibbs

Yes: vi on Linux, Notepad on Windows. (I compile the same source code for both systems, and edit it on whichever one is more appropriate at the time.)

It seems that the only truly effective and portable solution is to store the code with no tab stops (the hit on file size shouldn't be too bad in this era of cheap and plentiful disk space). Then I must find an editor (both Linux and Windows versions, please) which translates between runs of spaces and appropriate tab commands (as opposed to tab characters). Naturally, it must be smart enough to not touch quoted strings.

--
/~\  cgibbs@kltpzyxm.invalid (Charlie Gibbs) 
\ /  I'm really at ac.dekanfrus if you read it the right way. 
 Click to see the full signature
Reply to
Charlie Gibbs

I never learned emacs but reach for vi as a matter of course. I suppose I've used it for so long that I don't think about it BUT I probably only use a tiny part of it. And that's the point - one doesn't need to learn it all. A few simple commands are enough.

They follow a familiar pattern, too. So once that is understood then vi can be quite useful.

--
James Harris
Reply to
James Harris

Most editors I use can work with variable width tabs and in fact, usually remember the setting.

--

Rick C
Reply to
rickman

So you reset the tab setting and all is good.

Why can't a Windows box format tabs the way you want?

--

Rick C
Reply to
rickman

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.