LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Ed editor confusion with how the lines are spaced out (https://www.linuxquestions.org/questions/linux-newbie-8/ed-editor-confusion-with-how-the-lines-are-spaced-out-4175633427/)

ziprun 07-06-2018 10:12 AM

Ed editor confusion with how the lines are spaced out
 
So I'm trying to adjust to ed as an editor and so far so good. However one confusion I have is how lines have a space between each other each time I press the enter key to go to the next line. yet ex doesn't do this. Ex puts each line right above or below each other with the prompt being separated from the output rather than right below it as a blank line. If I could demonstrate what I mean I'll show how a bit of the famous ed email would be printed in ed vs ex if I pressed the enter key to go to the next line:
ed-
Quote:

From: patl@athena.mit.edu (Patrick J. LoPresti)
:
Subject: The True Path (long)
:
Date: 11 Jul 91 03:17:31 GMT
:
Newsgroups: alt.religion.emacs,alt.slack
:

:
When I log into my Xenix system with my 110 baud teletype, both vi
:
*and* Emacs are just too damn slow. They print useless messages like,
:
'C-h for help' and '"foo" File is read only'. So I use the editor
:
that doesn't waste my VALUABLE time.
:

:
Ed, man! !man ed
:

:
ED(1) UNIX Programmer's Manual ED(1)
:

:
NAME
:
ed - text editor
:

:
SYNOPSIS
:
ed [ - ] [ -x ] [ name ]
:
DESCRIPTION
:
Ed is the standard text editor.
:
---
:

:
Computer Scientists love ed, not just because it comes first
:
alphabetically, but because it's the standard. Everyone else loves ed
:
because it's ED!
:

:
"Ed is the standard text editor."
And if I did it in ex-
Quote:

From: patl@athena.mit.edu (Patrick J. LoPresti)
Subject: The True Path (long)
Date: 11 Jul 91 03:17:31 GMT
Newsgroups: alt.religion.emacs,alt.slack

When I log into my Xenix system with my 110 baud teletype, both vi
*and* Emacs are just too damn slow. They print useless messages like,
'C-h for help' and '"foo" File is read only'. So I use the editor
that doesn't waste my VALUABLE time.

Ed, man! !man ed

ED(1) UNIX Programmer's Manual ED(1)

NAME
ed - text editor

SYNOPSIS
ed [ - ] [ -x ] [ name ]
DESCRIPTION
Ed is the standard text editor.
---

Computer Scientists love ed, not just because it comes first
alphabetically, but because it's the standard. Everyone else loves ed
because it's ED!

"Ed is the standard text editor."
Is there something I'm doing wrong? Because I could have sworn that ed was capable of printing each line similar to ex without the need for having a blank line to separate each line.

GazL 07-06-2018 11:21 AM

With 'ex', after the user presses enter the prompt line is erased to start of line, overwritten with the new line of output and then the prompt is re-written below it. ed doesn't go to that trouble: it simply outputs the line and repeats the prompt without erasing, that's why they look different. It's just the way they work.

If you use the '-p' option to give ed a decent prompt it's much easier to understand what is happening.
e.g.
Code:

$ ed -p "ed> " /etc/hosts
1001
ed> 1
# /etc/hosts ###########################################################
ed>
#
ed>
#  Hostname to address mappings for the TCP/IP subsystem.
ed>
#
ed>

ed>
# loopback
ed> 1,7p
# /etc/hosts ###########################################################
#
#  Hostname to address mappings for the TCP/IP subsystem.
#

# loopback
127.0.0.1              localhost
ed>


ziprun 07-06-2018 04:54 PM

Quote:

Originally Posted by GazL (Post 5876322)
With 'ex', after the user presses enter the prompt line is erased to start of line, overwritten with the new line of output and then the prompt is re-written below it. ed doesn't go to that trouble: it simply outputs the line and repeats the prompt without erasing, that's why they look different. It's just the way they work.

I could have sworn that a version of ed I used once was able to work like how ex works. I think it was the plan 9 port of ed. Maybe I'm remembering it wrong, but has ed ever had the ability to have the prompt not be directly below the line and not separate each line with a blank line for the prompt (like in ex) and have it be shown exactly like how it would be shown if it was vi?

GazL 07-06-2018 06:07 PM

Perhaps it's implementation specific. I checked gnu ed and OpenBSD ed and they both work like that. If there's a way to disable the prompt lines to get the same behavior as ex ('P' doesn't do enough) I'd be interested to know how myself*.


* not that I use ed that often these days! :)

MadeInGermany 07-07-2018 04:56 AM

To redraw a line, isn't that a terminal capability?
And wasn't ed designed to not require a terminal?

GazL 07-07-2018 05:11 AM

Yes, ed dates back to the days of teletypes where you couldn't physically erase to start of line in the manner that 'ex' does. It's probably still using 'cooked' input too, so I doubt there's an option to do what the OP wants. I guess he'll just have to make do with the 'p' and 'n' commands.

ziprun 07-08-2018 11:13 AM

Quote:

Originally Posted by MadeInGermany (Post 5876599)
To redraw a line, isn't that a terminal capability?
And wasn't ed designed to not require a terminal?

Quote:

Originally Posted by GazL (Post 5876603)
Yes, ed dates back to the days of teletypes where you couldn't physically erase to start of line in the manner that 'ex' does. It's probably still using 'cooked' input too, so I doubt there's an option to do what the OP wants. I guess he'll just have to make do with the 'p' and 'n' commands.

Are you both saying that ex wasn't capable of being used on a teletype machine?

MadeInGermany 07-08-2018 04:55 PM

Hmm, ex is a line editor as well.
But it requires a line redraw capability that was certainly not present in the early teletypes. I think the CR character was present, but it led to overtyping - rather than overwriting.

ziprun 07-09-2018 11:47 AM

Quote:

Originally Posted by MadeInGermany (Post 5877133)
Hmm, ex is a line editor as well.
But it requires a line redraw capability that was certainly not present in the early teletypes. I think the CR character was present, but it led to overtyping - rather than overwriting.

Wasn't em and ex specifically designed for screen terminals? Also, isn't pressing the return [ENTER] key for the next line only possible in GNU ed? How would have ed performed on a real teleprinter? Would there be a space between lines like in ed for a terminal when you press [ENTER]?

ziprun 07-12-2018 01:50 PM

Okay, I got my question answsered and I thank you for the help. If anyone with sufficient moderation rights wants to lock it, go ahead because I'm good now.


All times are GMT -5. The time now is 02:16 PM.