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

  • Home
  • SEARCH
  • 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 7533397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:42:51+00:00 2026-05-30T05:42:51+00:00

My ideal scenario would be to have Vim split into two windows – first

  • 0

My ideal scenario would be to have Vim split into two windows – first containing the script (python) that I am currently working on and the other showing the result of evaluating that script. This is what I have so far:

:autocmd BufWritePost *.py redir @p | execute 'silent w !python -' | redir END

When saving the script, the contents of the script is piped to the python command, the output of that command is stored in register p. What is the best way to get p into a new/empty buffer displayed in the other window?

Some things I have tried is blast | normal! "pp | bfirst (blast: new/empty buffer, bfirst: buffer containing python script) but this seems to leave me in the “output” buffer and for whatever reason I lose syntax highlighting and need to flip back and forth between the buffers to get it back. I would really like to do this all in place and avoid generating a temp dump file where I pipe the output of running the script and would prefer to avoid using any other external tools to “watch” the python script file and do something when it changes.

  • 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-05-30T05:42:52+00:00Added an answer on May 30, 2026 at 5:42 am

    My approach was to use the preview window. This allows you to always move to the correct window no matter how many windows you have. It also allows you to “ignore” the fact that the preview window is open when you want to exit vim (you can just do :q rather than :qa for instance).

    autocmd BufWritePost *.py call OutputWindow("python")
    autocmd BufWritePost *.rb call OutputWindow("ruby")
    
    function OutputWindow(executable)
        let filename=expand('%:p')
    
        " move to preview window and create one if it doesn't
        " yet exist
        silent! wincmd P
        if ! &previewwindow
            " use 'new' instead of 'vnew' for a horizontal split
            vnew
            set previewwindow
        endif
    
        execute "%d|silent 0r!" . a:executable . " " . filename
        wincmd p
    endfunction
    

    There may be a less verbose way to accomplish this but it appears to work pretty well as is.

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

Sidebar

Related Questions

I have a .net windows application that needs to run in full screen. When
I have a scenario where I have several classes that extend from a common
In an ideal RESTful API that supports multiple accounts, should each resource have it's
Anyone have any ideas on a good way to model the following scenario in
In my ideal world, what I'm looking for would exist as something along the
Here is my ideal solution: a free tool that reads a .csporj or .sln
I have a project whose artifacts are two dynamic libraries, let's say libX.dylib and
I wish to off-screen render a Control to some bitmap so that I have
in my scenario I have a Linq2SQL Data backend. my Dataobjects implement IDataErrorInfo to
I have a scenario where I want to dynamically add words of text to

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.