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 9162625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:15:19+00:00 2026-06-17T14:15:19+00:00

Vim has a built-in way for executing programs, namely :!start foo for Windows and

  • 0

Vim has a built-in way for executing programs, namely :!start foo for Windows and :!bar & for Unix. However, the problem I have with those is that they steal focus from Vim. I’d like to launch my build & test script, and while its working and showing output in its command window never have to manually switch back to GVim.

I have thought of 3 possible solutions:

  • Use Auto-It/AutoHotkey to set focus back to Gvim. Unfortunately that only works in Windows and it’s brittle.
  • Have another process watching my sourcecode, and let that process automatically launch the script when the sourecode changes. (Another process creating a new window does not steal focus). This is a bit gimmicky, as you need to hold off on writing files until you want to start the script, and sometimes write a useless change if you want to re-test even though nothing in the source changed.
  • Use a client-server architecture, where Vim sends the command over a socket or something similar. This is actually my preferred solution, if there is any existing cross-platform way to do it. (I would prefer not having an extra GVim instance running for this though.)

So what would be a good way to do this? I have tried AsyncCommander but unfortunately it also steals focus.

  • 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-17T14:15:20+00:00Added an answer on June 17, 2026 at 2:15 pm

    When I’m not using a nice build system like sbt that watches source code and re-builds/re-tests for me, I tend to come up with hacks like this:

     :map <F9> :!touch and-go<CR><CR>
    

    Here hitting F9 updates a file. Pick any key binding you like.
    (and of course you could do the same with imap for vim’s insert mode as well.)

    Then all one needs is a shell script that watches this file and executes the
    command that builds/tests your project. On unix, I’d just do:

     while stat -c "%Y" and-go; do sleep 1; done | 
     stdbuf -i0 -o0 uniq -c | 
     while read l; do 
        echo build...;  # Your build/test execution commands here.
     done
    

    Running that in a separate window will be neat, because your vim/gvim window will retain it’s focus throughout, while you just keep hitting F9 (or whatever) and glancing at this other window to see how your build went.

    If you’re up to writing a windows batch script (or powershell, I don’t know) version of that as well, you should be good to go.

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

Sidebar

Related Questions

I have two text file. file1.txt has: gedit google chrome git vim foo bar
I has in vim: foo barba[r]bar foo [] indicates cursor position and when I
Maybe someone has a way to always start vim with scratch buffer? Ideally always
I am wondering whether vim has something like an API used by other programs.
I'm looking for a way to retrieve what has been entered in vim and
I am learning VIM. The VIM folder in the windows has two subdirectories VIM72
I'm using vim in Windows with mswin.vim included. It has mapped <C-S> to save
I recently switched from Vim to MacVim because it has Ruby support, however, the
ViM has this option hlsearch where a searched string is displayed in highlight mode
Vim has the terrific shortcut [{ for going to the last open { character.

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.