views:

72

answers:

1

When using the programmers text editor vi, I'll often using a wildcard search to be lazy about the file I want to edit

vi ThisIsAReallLongFi*.txt

When this matches a single file it works great. However, if it matches multiple files vi does something weird.

First, it opens the first file for editing

Second, when I :wq out of the file, I get a message the bottom of the terminal that looks like this

E173: 4 more files to edit
Hit ENTER or type command to continue

When I hit enter, it returns me to edit mode in the file I was just in. The behavior I'd expect here would be that vi would move on to the next file to edit.

So,

  1. What's the logic behind vi's behavior here

  2. Is there a way to move on and edit the next file that's been matched?

And yes, I know about tab completion, this question is based on curiosity and wanting to understand the shell better.

+8  A: 

vi supports having multiple files available for editing. :n goes to the next file, :N goes to the previous. Use :h arglist for more information.

Ignacio Vazquez-Abrams
Another decade old mystery solved. Thanks!
Alan Storm