循環瀏覽 ZSH History-incremental-pattern-search-backward 中的匹配項

循環瀏覽 ZSH History-incremental-pattern-search-backward 中的匹配項

我最近切換使用歷史搜索,history-incremental-pattern-search-backward因為它允許在搜索中使用模式。這是我的設定方式.zshrc

bindkey -M vicmd '/' history-incremental-pattern-search-backward

這很好用,但我不知道如何從搜尋選單轉到下一場比賽。

% cat foobarbaz.txt
bck-i-search: f*baz

有綁定鍵可以執行此操作嗎?

答案1

終於找到正確的咒語了。您需要在插入模式下映射模式搜尋。這就是我所缺少的部分:

# Search backwards and forwards with a pattern
bindkey -M vicmd '/' history-incremental-pattern-search-backward
bindkey -M vicmd '?' history-incremental-pattern-search-forward

# set up for insert mode too
bindkey -M viins '^R' history-incremental-pattern-search-backward
bindkey -M viins '^F' history-incremental-pattern-search-forward

我本來會^B在插入模式下用於向後搜索,但我已將其映射到其他內容。現在^R循環^F瀏覽比賽。

答案2

根據zshzlezsh 4.3.10的手冊頁,預設情況下沒有綁定密鑰。您需要為isearch地圖新增綁定,並且只有少數小工具可用。例如,您可以這樣做:

bindkey -M isearch '^R' history-incremental-search-backward
bindkey -M isearch '^S' history-incremental-search-forward

相關內容