News for hackers. Stuff that matters.
Re:Helping a Million Developers Exit Vim by bandrami on Tuesday May 23, 2017 @01:58PM (#14403508)
(Attribution is questionable, but as a geezer I feel the need to make sure the younger generations at least are familiar with this:)

ed is the standard text editor

Let's look at a typical novice's session with the mighty ed:

  golem> ed

  ?
  help
  ?
  ?
  ?
  quit
  ?
  exit
  ?
  bye
  ?
  hello? 
  ?
  eat flaming death
  ?
  ^C
  ?
  ^C
  ?
  ^D
  ?

  ---
  Note the consistent user interface and error reportage.  Ed is
  generous enough to flag errors, yet prudent enough not to overwhelm
  the novice with verbosity.
(As a geezer, I also have to say I really am impressed with ed in some ways, and you should never be afraid to try it when you have a specific and known edit you want to do.)
Re:Helping a Million Developers Exit Vim by waldir on Tuesday May 23, 2017 @02:20PM (#14403749)
After reading lots of similar anecdotes about Ed (Steven Levy's "Hackers" dedicates quite a few words to it), I was quite sure it was pretty much unusable for today's UI patterns, but also morbidly curious about how it might eventually work.

Then I came across "Actually using ed"[1], which did such a great job at explaining how to use the tool that I decided to throw in my 2 cents by submitting an entry to the tldr-pages project[2]. The rendered page looks can be found on [3]. Any feedback welcome!

1. https://sanctum.geek.nz/arabesque/actually-using-ed/

2. https://github.com/tldr-pages/tldr/pull/944

3. https://github.com/tldr-pages/tldr/blob/master/pages/common/...

Re:Helping a Million Developers Exit Vim by JdeBP on Friday May 26, 2017 @12:16PM (#14425105)
... and discussed on Hacker News recently at https://news.ycombinator.com/item?id=13113556 .
Re:Helping a Million Developers Exit Vim by geofft on Tuesday May 23, 2017 @02:01PM (#14403536)
"When I use an editor, I don't want eight extra KILOBYTES of worthless help screens and cursor positioning code! I just want an EDitor!! Not a “viitor”. Not a “emacsitor”. Those aren't even WORDS!!!! ED! ED! ED IS THE STANDARD!!!"

https://www.gnu.org/fun/jokes/ed-msg.txt

Re:Helping a Million Developers Exit Vim by srcmap on Tuesday May 23, 2017 @02:33PM (#14403883)
Using vi/vim lets one enter a secret dark corner of programmer society.

Memorize vi keystrokes is knowing the secret handshakes.

Able to Exit vim is finding the door to enlightenment.

If vi comes with an easy "back" button like all browsers, no-one will learn it. One needs to be trapped inside for a while to feel the power of the dark side.

Re:Helping a Million Developers Exit Vim by throwaway7645 on Tuesday May 23, 2017 @07:52PM (#14406489)
Is ":q!" really that crazy after 2 secs with Google?
Re:Helping a Million Developers Exit Vim by Certhas on Tuesday May 23, 2017 @09:26PM (#14406931)
Yes it is, if you are coming from a GUI life, start using the shell for the first time, and suddenly get thrown into some unnamed editor by git. :P

It breaks about every convention on editors and discoverability that you're used to.

Start GNU nano. It puts me in a position where typing edits the file I opened. It shows me the name of the program. It shows some keyboard shortcuts for interacting with the program. (Though for beginners the ^X syntax isn't obvious either).

Vim, doesn't give me any of that. I infrequently use vim and I still tend to open a file and start typing without hitting i first, because it's behaviour that's inconsistent with every single other editor I have ever used.

Re:Helping a Million Developers Exit Vim by netzone on Wednesday May 24, 2017 @05:19AM (#14408655)
My worst memories of starting out with programming is doing a git merge or pull, then before the command was done, I'd start typing git push or... and then I got stuck in insert mode. This was after I had learned that :q och :wq! did the job, and I could not for the life of me figure out how to get out of insert mode.

Fun times.

Re:Helping a Million Developers Exit Vim by throwaway7645 on Wednesday May 24, 2017 @06:53AM (#14409015)
Or because every other editor you've had is inconsistent with Vim. It is dumb if people are being dumped there by Git. I guess if you try to use it and get stuck it is a lot easier to escape than if someone gets dumped there without even knowing where they are.
Re:Helping a Million Developers Exit Vim by kefabean on Wednesday May 24, 2017 @07:53AM (#14409282)
Or (I'm surprised it's not been mentioned already): Shift-ZZ to save and close (saves an extra keystroke)
Re:Helping a Million Developers Exit Vim by aequitas on Tuesday May 23, 2017 @03:08PM (#14404215)
I recently had to use ed. I wanted to write a handful lines of code, but for that I needed the context that was in the terminal history. I didn't want to keep switching back and for with vi. So I decided this was the time I should learn ed. It did the job it was expected to do, I was not disappointed.
Re:Helping a Million Developers Exit Vim by bandrami on Tuesday May 23, 2017 @03:18PM (#14404300)
Same way I came to it. It's exactly what it claims to be, nothing more or less, and it does what it does very well.
Re:Helping a Million Developers Exit Vim by FreeFull on Tuesday May 23, 2017 @02:05PM (#14403589)
Also keep in mind that ex is a part of vi and vim, and is an improved version of ed. All : commands in vi(m) are actually ex commands
Re:Helping a Million Developers Exit Vim by bandrami on Tuesday May 23, 2017 @02:15PM (#14403698)
Excellent point. I'm an Emacs guy by habit, but I'm also a sysadmin, which means I keep a well-stocked repertoire of ex commands ready for when the shit really hits the fan.
Re:Helping a Million Developers Exit Vim by iamacynic on Tuesday May 23, 2017 @07:25PM (#14406347)
ex is a good way to script in-place text edits using the commands you're familiar with in vim. just be careful.
Re:Helping a Million Developers Exit Vim by jzl on Tuesday May 23, 2017 @03:55PM (#14404675)
I got a kick out of discovering recently that there are still significant new releases of ed. For example:

http://lists.gnu.org/archive/html/bug-ed/2017-01/msg00002.ht...

Re:Helping a Million Developers Exit Vim by kccqzy on Tuesday May 23, 2017 @02:05PM (#14403579)
I find that with a specific and known edit, it's far easier to do using sed and awk. In particular awk Has better power-to-weight ratio at traditional text processing. I think typical awk scripts could very well be shorter than the equivalent python scripts that do the same thing.
Re:Helping a Million Developers Exit Vim by bandrami on Tuesday May 23, 2017 @02:18PM (#14403733)
Awk is probably the most powerful "taken for granted" utility in all of the unix ecosystem.
Re:Helping a Million Developers Exit Vim by throwaway2016a on Tuesday May 23, 2017 @03:24PM (#14404362)
I have written hundred+ line awk programs. For stream text editing it is excellent at what it does and it's install base is huge. Rarely do I encounter a *nix machine without it on there.
Re:Helping a Million Developers Exit Vim by throwaway7645 on Tuesday May 23, 2017 @07:50PM (#14406482)
Perl & Python are also installed on most UNIX machines I've seen. I know Perl was invented to address weaknesses with Awk. I use all 3 to some degree, but is there a reason you like Awk?
Re:Helping a Million Developers Exit Vim by flukus on Wednesday May 24, 2017 @02:23AM (#14407954)
The pattern -> action format of awk is really nice for simple apps, it's a built in for loop + switch statement that reads from stdin. It's also simple to change what the record/column seperators are, so it can handle some quite complex data shapes with zero code.

Awk and python don't deal with stdin/stdout quite as nice (AFAIK) and there is always the temptation to do too much with them.

As an example, the other day I wrote a DSL in awk, it takes a mostly CSV file in and outputs sql commands. If you did it in python you could run the sql directly, but the awk stdio version makes it easier to combine as needed. If I want to run the generated sql I can pipe that to the sql cli client, if I need to hand it to QA I can just pipe to a file etc.

Re:Helping a Million Developers Exit Vim by throwaway7645 on Wednesday May 24, 2017 @06:55AM (#14409025)
Neat, will have to look into that. I think Perl might have a command line switch with similar behavior that runs your command across every line of whatever you pipe to it, but that might not be what you're saying.
Re:Helping a Million Developers Exit Vim by throwaway2016a on Wednesday May 24, 2017 @08:16AM (#14409410)
flukus, thank you. I was trying to say something like that but wasn't able to quite word it right.
Re:Helping a Million Developers Exit Vim by yjftsjthsd-h on Wednesday May 24, 2017 @12:10AM (#14407559)
> Rarely do I encounter a nix machine without it on there.

Isn't it posix mandated?

Re:Helping a Million Developers Exit Vim by throwaway2016a on Wednesday May 24, 2017 @08:19AM (#14409429)
yjftsjthsd-h, I'm curious so I looked it up but couldn't find anything. AFAIK POSIX only specifies operating system behavior and doesn't specify any actual apps but I could be wrong there. In any case, the rise of containerization has brought many nano Linux distributions that often have even fewer packages than even the most minimal distributions of years past.
Re:Helping a Million Developers Exit Vim by kccqzy on Thursday May 25, 2017 @08:56PM (#14421349)
No, actually POSIX does mandate awk to be present:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/aw...

Re:Helping a Million Developers Exit Vim by bonzini on Tuesday May 23, 2017 @05:02PM (#14405324)
I suspect that sed -i (and before that perl -i) made ed even less relevant than before.
Re:Helping a Million Developers Exit Vim by Nimitz14 on Tuesday May 23, 2017 @04:48PM (#14405187)
Next you're going to tell us 1+1=2!
Re:Helping a Million Developers Exit Vim by agumonkey on Tuesday May 23, 2017 @05:43PM (#14405639)
I love ed