如何在ZSH/终端中设置VIM键绑定。

huangapple go评论54阅读模式
英文:

How to set VIM key binding in ZSH/terminal

问题

在我正常使用Vim的过程中,我有一个键绑定("jj")来进入“NORMAL”模式。我通过在~/.vimrc中设置映射配置来实现这一点 -> :imap jk <Esc>。然而,在Mac OS终端中,ZSH中不起作用。是否有一种方法可以启用此功能?

编辑/更新:我偶然发现了这个问题,它似乎间接地回答了我的问题,但是在问题中提到了其他内容(不是答案)。我将保持此问题开放,因为原始线程并没有直接回答这个问题。

英文:

In my normal use of Vim I have a key binding ("jj") to enter NORMAL mode. I accomplish this by setting a mapping configuration in ~/.vimrc -> :imap jk <Esc>. However this binding does not take effect in ZSH on Mac OS Terminal. Is there a way to enable this?

Edit/Update: I came across this question which appears to sort of indirectly answer my question within its question to something else (not its answer). Leaving this open as that original thread does not directly answer the question

答案1

得分: 1

ZSH和Vim分别在~/.zshrc~/.vimrc中进行配置。您可以通过将以下行添加到您的~/.zshrc文件中,将jj键绑定到您的zsh终端。

# 将“jj”快捷方式添加为进入NORMAL模式
bindkey -M viins 'jj' vi-cmd-mode
英文:

ZSH and Vim are configured separately, in ~/.zshrc and ~/.vimrc respectively. You can add the jj key binding to your zsh terminal by adding the following line to you ~/.zshrc file.

# Add "jj" shortcut to enter NORMAL mode
bindkey -M viins 'jj' vi-cmd-mode

huangapple
  • 本文由 发表于 2023年5月26日 15:49:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/76338714.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定