Reputation: 24334
How can I configure Vim/bash to open all files in separate tab when I run vim *
(with no other parameters)?
Moreover, can I configure Vim to do a filter of the files given, i.e. I would like to store file extensions that Vim should consider? For example, suppose I have a directory with following files:
program1.h
program1.cc
program1.o
program2.cpp
I would like Vim open only .h
, .cc
and .cpp
files.
Upvotes: 0
Views: 196
Reputation: 45117
The simple answer:
vim -p *.h *.cc *.cpp
As @Brian Tiffin mentioned the -p
flag opens the files in tabs. The rest is just normal unexciting file globbing.
Note: -p
will default to opening a max of 10 tab pages.
Personally I would just open up vim without any parameters and just open the files with :e
as needed. If you really do need a list of files I would pass the files in via globs from the command line or use :args
to populate the arglist. e.g. :args *.h *.cc *.cpp
...What about the no parameter restriction?
You are essentially asking to either white-list or black-list certain filetypes. Such a behavior is both confusing and potentially causes surprises down the road. A related solution is to use 'wildignore'
.
It also seems like you are doing a heavily tab centric workflow. I know it might sound weird but maybe use less tab panes and more buffers. Here are some nice posts about it:
:h -p
:h :e
:h arglist
:h 'wildignore'
Upvotes: 2
Reputation: 51613
First of all, why don't you want to give other parameters for vim
?
Still you can do it like (in your .vimrc
):
au BufAdd,BufNewFile * nested tab sball
For the second part, you can do it like:
au BufAdd,BufNewFile *.o bdelete!
Still for this I'd recommend to use something like a bash
function like parsing the parameter list to the function and rejecting file(mask)s you don't want to edit, and pass the filtered list to vim
(as the above solution still opens the *.o
files, which can be slow, etc.)
Upvotes: 1