LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-06-2018, 11:12 AM   #1
ziprun
Member
 
Registered: Apr 2018
Posts: 33

Rep: Reputation: Disabled
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.
 
Old 07-06-2018, 12:21 PM   #2
GazL
Senior Member
 
Registered: May 2008
Posts: 4,800
Blog Entries: 14

Rep: Reputation: Disabled
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>
 
1 members found this post helpful.
Old 07-06-2018, 05:54 PM   #3
ziprun
Member
 
Registered: Apr 2018
Posts: 33

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by GazL View Post
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?
 
Old 07-06-2018, 07:07 PM   #4
GazL
Senior Member
 
Registered: May 2008
Posts: 4,800
Blog Entries: 14

Rep: Reputation: Disabled
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!

Last edited by GazL; 07-06-2018 at 07:10 PM.
 
Old 07-07-2018, 05:56 AM   #5
MadeInGermany
Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 955

Rep: Reputation: 419Reputation: 419Reputation: 419Reputation: 419Reputation: 419
To redraw a line, isn't that a terminal capability?
And wasn't ed designed to not require a terminal?
 
Old 07-07-2018, 06:11 AM   #6
GazL
Senior Member
 
Registered: May 2008
Posts: 4,800
Blog Entries: 14

Rep: Reputation: Disabled
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.
 
Old 07-08-2018, 12:13 PM   #7
ziprun
Member
 
Registered: Apr 2018
Posts: 33

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by MadeInGermany View Post
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 View Post
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?
 
Old 07-08-2018, 05:55 PM   #8
MadeInGermany
Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 955

Rep: Reputation: 419Reputation: 419Reputation: 419Reputation: 419Reputation: 419
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.
 
Old 07-09-2018, 12:47 PM   #9
ziprun
Member
 
Registered: Apr 2018
Posts: 33

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by MadeInGermany View Post
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]?
 
Old 07-12-2018, 02:50 PM   #10
ziprun
Member
 
Registered: Apr 2018
Posts: 33

Original Poster
Rep: Reputation: Disabled
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] to get delete the blank lines from vi editor. vaibhavs17 Linux - Newbie 3 07-09-2012 04:09 PM
Comment out next 40 lines with vi-editor? Ujjain Linux - Software 3 07-06-2009 02:46 AM
Need help appending text to lines in a file using vi editor tmbrwolf53 Linux - Newbie 3 10-31-2008 04:25 PM
how do I delete *certain* lines in vi editor? zim64half Linux - General 3 04-23-2007 08:39 PM
copy lines in vi editor jkmartha Linux - Newbie 4 05-14-2005 03:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration