gpt4 book ai didi

function - 如何在 Vim 函数中模拟按键?

转载 作者:行者123 更新时间:2023-12-02 13:50:23 26 4
gpt4 key购买 nike

我将从代码开始

function BigScrollUp()
let count = 20
while count > 0
"Press" CTRL-Y <-- how do I emulate this?
sleep 5m
count -= 1
endwhile
endfunction

我想创建一个带有动画的快速上下滚动功能,以便我可以跟踪我要去的地方。

最佳答案

您可以使用feedkeys()。输入 :help feedkeys 以了解更多信息:

feedkeys({string} [, {mode}])               *feedkeys()*
Characters in {string} are queued for processing as if they
come from a mapping or were typed by the user. They are added
to the end of the typeahead buffer, thus if a mapping is still
being executed these characters come after them.
The function does not wait for processing of keys contained in
{string}.
To include special keys into {string}, use double-quotes
and "\..." notation |expr-quote|. For example,
feedkeys("\<CR>") simulates pressing of the <Enter> key. But
feedkeys('\<CR>') pushes 5 characters.
If {mode} is absent, keys are remapped.
{mode} is a String, which can contain these character flags:
'm' Remap keys. This is default.
'n' Do not remap keys.
't' Handle keys as if typed; otherwise they are handled as
if coming from a mapping. This matters for undo,
opening folds, etc.
Return value is always 0.
<小时/>
call feedkeys("\<C-Y>")

关于function - 如何在 Vim 函数中模拟按键?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9445273/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com