static_rtti
static_rtti

Reputation: 56262

Is there a way to open multiple files at once from vim?

When launching vim from the command line, I can do for example vim *.txt to open all text files in a directory at once.

For some reason, trying the same from inside vim ( :e *.txt ) gives an error: E77: Too many file names.

Is there a reason why vim refuses to open multiple at once? Is there a way to change that?

Upvotes: 52

Views: 11333

Answers (4)

Kasper-34
Kasper-34

Reputation: 47

:args *.txt also works.

If it helps there is more information on this topic at :help argument-list and :help 07.2. Both of those sections help explain how to use the argument list and how the buffer list is not the same thing.

Upvotes: 1

romainl
romainl

Reputation: 196546

It's done in two operations.

Open all *.js files in as many vertical splits:

:argadd *.js
:argdo vs

in horizontal splits:

:argdo sp

in tabs: 

:argdo tabe

Upvotes: 15

Tyler Durden
Tyler Durden

Reputation: 11532

Also, to add to the other answers, when you first start vim you can open multiple files at the same time, e.g.:

vim *.txt

Upvotes: -2

William Pursell
William Pursell

Reputation: 212248

This should work :

:next *.txt

Upvotes: 81

Related Questions