vim 识别窗口
我有一个函数,它打开一个包含脚本结果的新窗口,
function! MyFunc()
bo new
se buftype=nofile
silent! exec "r! sh MyScript.sh "
endfunction
我想识别这个特定窗口,以便我可以多次调用我的函数并每次使用相同的窗口,而不是打开一个新窗口。
类似的东西
if exists(myWindow)
use myWindow
else
bo new
endif
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我认为这可能有用...但是...请小心行事,因为我不是 Vim 专家。
当您第一次创建窗口时,您可以将其保存在全局中:
随后您可以检查该缓冲区是否存在:
设置“swb=usetab”将意味着当
sbuf
切换到缓冲区时,它将转到当前打开的任何窗口/选项卡(如果已打开)。我不喜欢像这样全局设置 swb,只是为了一个 sbuf 调用。有人知道更好的方法吗?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:
and subsequently you can check to see if that buffer exists:
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?