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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:08:54+00:00 2026-05-24T10:08:54+00:00

I have a function which opens a new window containing the results of a

  • 0

I have a function which opens a new window containing the results of a script

function! MyFunc()
    bo new
    se buftype=nofile
    silent! exec "r! sh MyScript.sh "
endfunction

I’d like to identify this specific window so that I can call my function multiple times and use the same window each time rather than opening a new window.

something like

if exists(myWindow) 
    use myWindow
else
    bo new
endif
  • 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-24T10:08:54+00:00Added an answer on May 24, 2026 at 10:08 am

    Ok I think this might work… but… tread carefully because I am no Vim expert.

    When you create the window the first time you can save it in a global:

    bo new
    set buftype=nofile
    let g:my_run_buffer = bufnr("%")
    

    and subsequently you can check to see if that buffer exists:

    if bufexists(g:my_run_buffer)
        " Go to buffer
        set swb=usetab
        exec "sbuf " . g:my_run_buffer
    else
        ... create it ...
    endif
    

    Setting “swb=usetab” will mean that when sbuf switches to the buffer, it will go to whatever window/tab it is currently open in, if it is open. I don’t like setting swb globally like that, just for one sbuf call. Anyone know a better way?

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

Sidebar

Related Questions

I have a script that makes barplots, and opens a new window when 6
Hey, on a page I have a link which opens up a new window
I have a Greasemonkey script which operates on a search results page at a
I have a window which opens up on a button click. The window takes
I have a parent window in which a push-button's click event function has the
I have an application that opens a new window on clicking a link. This
On Click of a button, opens a window in which i have a form
I have defined a function in which i want to open a page on
I have a function which parses one string into two strings. In C# I
I have a function which searches an STL container then returns the iterator when

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.