lagsalot
lagsalot

Reputation: 513

How to open and split multiple files

How can I open in a split window multiple files. One split for each file if I'm not being clear.

I want to do something like. :sp app/views/*.erb and have the ~7 files all open in their own split windows.

Upvotes: 40

Views: 16313

Answers (5)

James F
James F

Reputation: 1066

vim -O app/views/*.erb

This is also from the shell. It will open as vertical splits.

Upvotes: 23

Henrik N
Henrik N

Reputation: 16294

Just learned from tonymec@#vim that you can do

:args app/views/*.erb | all

for horizontal splits or

:args app/views/*.erb | vertical all

for vertical.

Upvotes: 32

lagsalot
lagsalot

Reputation: 513

Had to whip up a function.

  fun! OpenSplits(dir)
    for f in split(glob(a:dir), '\n')
      execute "sp " f
    endfor
  endfun

Upvotes: 1

user80168
user80168

Reputation:

Not actually from within vim, but perhaps you can run vim like this:

vim -o app/views/*.erb

Upvotes: 63

Rob Wells
Rob Wells

Reputation: 37159

What happens when you do a

:sf app/views/*.erb

from within vim?

Upvotes: 3

Related Questions