Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8530931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:22:05+00:00 2026-06-11T09:22:05+00:00

I am trying to automate some manual labor, using a bash script. Basically I

  • 0

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).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:22:06+00:00Added an answer on June 11, 2026 at 9:22 am

    There are at least four ways to do this:

    1. vim -s <(echo $':vsplit A12.m\n:hsplit A22.m\n…')
      
    2. vim -S <(echo $'vsplit A12.m\nhsplit A22.m\n…')
      

      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:

      vim -S <(cat <<<EOF
      vsplit A12.m
      hsplit A22.m
      …
      EOF
      )
      
    3. vim -c 'vsplit A12.m | hsplit A22.m | …'
      

      You can have multiple -c keys which are run in sequence, but not more then ten thus you have to join commands in one -c with bar.

    4. Instead of a bash script use vim one:

      #!/usr/bin/vim -S
      vsplit A12.m
      hsplit A22.m
      …
      

      . Then you can chmod +x it and run like any other executed file. Vim treats #! as a comment leader just for that reason.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to automate some of my interactions with git using bash scripts.
I'm trying to automate some processes using Robot and it seems certain keycodes (only
I'm trying to automate some excel processing. With autoit I open several Excel with
I'm trying to automate the download of some data from a webform. I'm using
I am trying to automate some Weka classification using Java code. I'm getting the
I'm trying to automate some command line tests on Windows and Unix. I'm using
Im trying to automate the installation of some custom software using cpanel/whm and postwwwacct
I am trying to automate some authentication where I connect via RDP, and authenticate
trying to automate using perl scripts on windows server using MediaWiki::Bot and Mediawiki::API taken
I'm trying to automate sending many jobs to a server using the qsub command.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.