< Previous | Contents | Next >
Opening Additional Files For Editing
It's also possible to add files to our current editing session. The ex command :e (short for “edit”) followed by a filename will open an additional file. Let's end our current editing session and return to the command line.
Start vi again with just one file:
[me@linuxbox ~]$ vi foo.txt
[me@linuxbox ~]$ vi foo.txt
To add our second file, enter:
:e ls-output.txt
:e ls-output.txt
And it should appear on the screen. The first file is still present as we can verify:
:buffers
1 # "foo.txt"
2 %a "ls-output.txt"
line 1
line 0
:buffers
1 # "foo.txt"
2 %a "ls-output.txt"
Press ENTER or type command to continue
Press ENTER or type command to continue
Note: You cannot switch to files loaded with the :e command using either the :n or :N command. To switch files, use the :buffer command followed by the buf- fer number.