开发者

Backward search in vi-mode [closed]

开发者 https://www.devze.com 2023-01-04 17:36 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a开发者_开发百科 comment to explain where the question may be able to be answered.

Closed 8 years ago.

Improve this question

I just discovered the possibility to use vi-mode in zsh. Pretty awesome. But I used CTRL-r in emacs-mode pretty much and really really miss it. Is there something alike or can I get that functionality in vi-mode as well?


You can bind history-incremental-search-backward to any key, for example:

bindkey -M vicmd '?' history-incremental-search-backward


According to this answer: https://unix.stackexchange.com/a/30169

you can actually bind in vim-mode to the history search:

bindkey '^R' history-incremental-search-backward

According to a comment to the answer you can also bind to history-incremental-pattern-search-backward

bindkey '^R' history-incremental-pattern-search-backward

Then you do a history pattern search with

example: <C-R> mv * /target


This is the solution: up/down allows to either browse history (if field is empty) or search. Made my day.

bindkey '^[[A' up-line-or-search
bindkey '^[[B' down-line-or-search
0

精彩评论

暂无评论...
验证码 换一张
取 消