如何执行缓冲区的内容? [英] How to execute the contents of a buffer?
问题描述
我有一个正在当前缓冲区中开发的 vim 脚本,我想执行它.有什么简单的方法吗?
I have a vim script I'm developing in my current buffer and I want to execute it. Is there a simple way to do it?
经过长时间的搜索,我只找到了两种相关的方法,但并不完全是我要找的:
After a long search I have only found two related ways, but not exactly what I'm looking for:
a) source"命令 - 但要使用它,我首先需要将内容保存到文件,然后source"回来,这看起来并不简单
a) "source" command - but to use it I first need to save the content to file and then "source" it back, which doesn't look simple
b) 调用"命令 - 但我不想调用我的函数,我想执行整个文件,它定义了几个函数并且在函数之外有一些代码
b) "call" command - but I don't want to call my function, I want to execute the whole file, which defines several functions and has some code outside of functions at all
推荐答案
使用:
:%y" (alternatively: ggyG)
:@"
它将整个缓冲区复制到默认寄存器中,然后运行它.
It will copy whole buffer into default register and then run it.
参见 :help :y
和 :help :@
(也可能是 :help range
).
See :help :y
and :help :@
(and also :help range
maybe).
这篇关于如何执行缓冲区的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!