8

Using ex I open 3 files

ex file1 file2 file3

I know

  • the command :n goes to file 2 and file3
  • the command :rew go to file1 from file3 or file2

But what command can I use to go to previous file? I think :e previousfile will work, but does something quicker like :n for previous exist?

Thomas Dickey
  • 75,040
  • 9
  • 171
  • 268
elbarna
  • 12,050
  • 22
  • 92
  • 170

1 Answers1

3

From the POSIX specifications for ex:

Implementations wanting to provide a counterpart to the next command that edited the previous file have used the command prev[ious], which takes no file argument. POSIX.1-2008 does not require this command.

So, in most implementations, :prev will do what you want. (That is, most implementations of ex that I've encountered; obviously you shouldn't rely on this for portable scripting.)

Note also that this is not the same as :p, which actually means to print the current line. prev is the shortest abbreviation allowed. (pre means "preserve".)

Wildcard
  • 35,316
  • 26
  • 130
  • 258