1

Is there a command in ed that repeats the last command? I know that one can repeat the last search (with //) but a command to repeat and/or edit the last command without having to retype it would be helpful.

Kusalananda
  • 333,661
Edman
  • 492

1 Answers1

6

No, there is no magic command in ed that repeats the last command. If you are using G/re/ to interactively give editing commands on lines matching /re/, then you may use & to repeat the last such entered command, and you mentioned // to repeat the last search, as would ?? do (but backwards).

However, you can give ed a readline history and command line editing facilities using the rlwrap tool:

rlwrap ed somefile

This allows you to

  • press Up-arrow to recall recently entered commands etc., and to
  • move around on the current line of input (using vi or emacs editing mode depending on your setting of editing-mode in ~/.inputrc),
  • editing the current line of input as you would the shell's command line , before issuing a command.
  • It also gives you persistent history by saving it in a ~/.ed_history file.

See also man rlwrap once you have installed rlwrap using your package manager (or from GitHub).

Kusalananda
  • 333,661