I am trying to automate some manual labor, using a bash script. Basically I open multiple files with Vim in 1 terminal-window (and only one terminal-tab), using several splits, vsplits and tabs. I will now describe a general case to explain what I usually do manually.
I use 3 tabs (referring from here on as A, B and C) and I open 4 files in each tab in a 2×2 layout:
bash:~$ cd ~/Workspace/
bash:~/Workspace$ vim A11.m
:vsplit A12.m
:hsplit A22.m
"move cursor to A12.m"
:hsplit A21.m
:tabedit B11.m
:vsplit B12.m
:hsplit B22.m
"move cursor to B12.m"
:hsplit B21.m
:tabedit C11.m
:vsplit C12.m
:hsplit C22.m
"move cursor to C12.m"
:hsplit C21.m
What I would like to create is a shell script into which the file names and location(s) are hard-coded, which upon execution would do all the above. Can anyone suggest to me an approach which would make this possible (if possible at all)? Thanks in advance!
ps: In my .vimrc I have added some configurations such that :split opens the new file beneath (instead of above) the current file and :vsplit opens the new file to the right (instead of to the left).
There are at least four ways to do this:
it is similar to what @romainl, but you create the script by yourself and do not use any file besides the bash script itself (can be as well just an alias or a line in history). It is possible to use HERE-strings in bash, they are more readable:
You can have multiple
-ckeys which are run in sequence, but not more then ten thus you have to join commands in one-cwith bar.Instead of a bash script use vim one:
. Then you can
chmod +xit and run like any other executed file. Vim treats#!as a comment leader just for that reason.