TIL that vim 7 has the ability to work with tabs which is cool. Is there a way to tell vim through .vimrc that whenever I open multiple files, open them in tabs [instead of having to use -p always]
Asked
Active
Viewed 307 times
2
-
2create an alias maybe? – Kent Jul 09 '13 at 10:21
-
I understand you are asking me to alias vim to vim -p.. But can that be done in the vimrc file? – radiantRazor Jul 09 '13 at 10:24
2 Answers
3
How about this:
:autocmd VimEnter * argdo tabedit
This edits each file in the argument list (i.e. all files passed on the command line) in a new tab page. It's probably still a bit raw and doesn't handle corner cases too well, but see this as a starting point.

Ingo Karkat
- 167,457
- 16
- 250
- 324
-
For some reason when I try this & execute `vim 1 2 3`, the files are open in tabs all right but there is a fourth tab with an empty file. Any guesses why? – Paddu Jul 09 '13 at 11:05
-
Same here. Also it asks me to press ENTER once for every file before opening all of them: `"file1" 6500L, 2173458C "file_a_b_c" 2553 lines, 816646 characters Press ENTER or type command to continue "file_b_c_d" 10 lines, 100 characters Press ENTER or type command to continue` and so on.. – radiantRazor Jul 09 '13 at 11:28
-
@Paddu That's because of `:tabedit`; it should probably just `:edit` the first one. I hinted at this "raw" behavior; feel free to tweak it as you please. – Ingo Karkat Jul 09 '13 at 11:56
-
@radiantRazor Use `:silent` before either `argdo` or `tabedit` (should work in both locations), this way you will not get these messages. Try using `:execute "argdo tabedit" | tabclose 1` in place of `argdo tabedit` to remove both messages and first tab page. – ZyX Jul 09 '13 at 18:29
-
@ZyX, I added in my .vimrc `autocmd VimEnter * execute "argdo tabedit" | tabclose 1` and executed `vim 1 2 3` and found that three tabs where open, fir the files `2`, `3` and an empty file. – Paddu Nov 11 '13 at 11:17
3
Hm, I think slightly better then the tabedit autocommand from Ingo is
:au VimEnter * set tabpagemax=9999|sil tab ball|set tabpagemax&vim
which at least avoids the empty tabpage being created.

Christian Brabandt
- 8,038
- 1
- 28
- 32
-
Probably `all` is better than `ball` here so as to create a new tab for each page in the argument list rather than the buffer list? But I don't know under what cases the behaviour would differ between using `all` or `ball`. – Paddu Nov 11 '13 at 11:23