Editing Multiple files in vi with Wildcards

Posted by Alan Storm on Stack Overflow See other posts from Stack Overflow or by Alan Storm
Published on 2010-05-14T21:26:52Z Indexed on 2010/05/14 21:34 UTC
Read the original article Hit count: 291

Filed under:
|
|
|
|

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.

© Stack Overflow or respective owner

Related posts about vi

Related posts about shell