2014-10-06 48 views
1

我正在寫一個函數,它的作用類似於*鍵,但不移動光標。設置當前搜索模式很簡單:如何在不打開窗口的情況下添加Vim搜索記錄?

let @/='...' 

所以nN甚至//按預期方式工作。但*也增加了一個條目到搜索歷史。我想出的最好的是:

silent! normal! q/"/p 

但短暫打開搜索歷史的窗口,這導致難看閃爍,當我觸發功能。有沒有更好的辦法?

+0

你可能想看看Ingo Karkat的[SearchHighlighting](http://www.vim.org/scripts/script.php?script_id=4320)插件。這是多加一點。它也有其他可能有用的類似插件的鏈接 – 2014-10-06 19:45:33

回答

3

檢查: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,實際上)。

相關問題