vim tabe split open more than 10 files from command line -
i want open multiple .cpp .h files in pair tabe
, sp
commands. suppose current workplace has a.h, a.cpp, b.h, b.cpp, ... z.h, z.cpp.
i tried following:
vim a.cpp -c 'sp a.h' -c 'tabe b.cpp' -c 'sp b.h' -c 'tabe c.cpp' -c 'sp c.h' -c 'tabe d.cpp' -c 'sp d.h' -c 'tabe e.cpp' -c 'sp e.h' -c 'tabe f.cpp'
which work. however, number of -c
commands limited 10. if want open more 12 files, fail.
vim a.cpp -c 'sp a.h' -c 'tabe b.cpp' -c 'sp b.h' -c 'tabe c.cpp' -c 'sp c.h' -c 'tabe d.cpp' -c 'sp d.h' -c 'tabe e.cpp' -c 'sp e.h' -c 'tabe f.cpp' -c 'sp f.h' ...
will fail.
is there way make work?
you can use |
separate command in vim. can combine of -c
1 command , pass -c
vim a.cpp -c 'sp a.h | tabe b.cpp | sp b.h | tabe c.cpp | ...'
assuming in folder cpp , header files run
vim -p *.cpp -c 'tabdo sp %<.h'
to everything. -p
tells vim open files in tabs. every cpp file in directory have 1 tab. after vim loaded run sp %<.h
in each of tabs. where
%<.h
original filename extension change .h
. (%<
filename without extension. take @ :help %<
)
vim defaults having 10 tab pages. if need open more need increase tabpagemax
value.
set tabpagemax=100
take @ :help tabpagemax
(if need many tab pages recommend learning how use buffers)
Comments
Post a Comment