gpt4 book ai didi

vim - 如何在不打开窗口的情况下添加到 Vim 搜索历史记录?

转载 作者:行者123 更新时间:2023-12-02 17:36:48 24 4
gpt4 key购买 nike

我正在编写一个函数,它的作用类似于 * 键,但不会移动光标。设置当前搜索模式很简单:

let @/='...'

所以 nN 甚至 // 都按预期工作。但是 * 还会在搜索历史记录中添加一个条目。我想到的最好的是:

silent! normal! q/"/p

但这会短暂打开搜索历史窗口,这会在我触发该功能时导致丑陋的闪烁。有没有更好的办法?

最佳答案

检查 :help histadd()

histadd({history}, {item})              *histadd()*
Add the String {item} to the history {history} which can be
one of: *hist-names*
"cmd" or ":" command line history
"search" or "/" search pattern history
"expr" or "=" typed expression history
"input" or "@" input line history
"debug" or ">" debug command history
The {history} string does not need to be the whole name, one
character is sufficient.
If {item} does already exist in the history, it will be
shifted to become the newest entry.
The result is a Number: 1 if the operation was successful,
otherwise 0 is returned.

当编写 vimscript 时,信息来自 :help function-list可能非常有帮助(实际上是整个第 41 章)。

关于vim - 如何在不打开窗口的情况下添加到 Vim 搜索历史记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26223100/

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