On 5/11/06, Tim Chase <[EMAIL PROTECTED]> wrote:
> How can I open four files (eg: file1.txt, file2.txt, file3.txt and
> file4.txt) for a view as following:
>
> VIM
> ------------------------------------
> ¦file1 ¦file2 ¦
> ¦ ¦ ¦
> ¦ ¦ ¦
> ¦ ¦ ¦
> ¦ ¦ ¦
> ------------------------------------
> ¦file3 ¦file4 ¦
> ¦ ¦ ¦
> ¦ ¦ ¦
> ¦ ¦ ¦
> ¦ ¦ ¦
> ------------------------------------
>
> I tried this: with a modeline with :sp - but it don't works
> and a script with -o and -O, but also this don't works.
> Has anyone a good idea?
Ugly as it may be, the following worked for me:
vi -c 'to sp file1' -c 'bel vsp file2' -c 'wincmd b' -c 'bel
vsp file4' file3
The items might put in a script and sourced to make it a bit
cleaner...something like
bash$ cat four.vim
to sp file1
bel vsp file2
wincmd b
bel vsp file4
wincmd h
e file3
wincmd t
bash$ vim -c 'so four.vim'
Both seem to do the trick. They're kinda hard-coded, to
those file names, and those window positions, but they work.
You could also create a session with 4 empty window (with :mksession,
or I use my WinWalker.vim to create the layout and save the template
as a session).
Then a script something like the below should fill the windows. I.e.
$ tst.sh file1 file2 file3 file4
However, for some reason I can't find, it seems to eat one of the
windows before it gets going, so instead of 4 windows, it only has 3.
If the .vim script resulting from the below .sh script is "source"d
from inside Vim, it works find. Odd.
cat <<EOF >tst.vim
source ~/Session.4empty.vim
1 wincmd w
EOF
for file in $*
do
echo 'e' $file >> tst.vim
echo 'wincmd w' >> tst.vim
done
#gvim '-c so tst.vim'
gvim -S tst.vim