Vim - 将密钥绑定到 bash 命令

hkn*_*nik 6 vim

在 VIM 中,有没有办法将键绑定到 shell 命令?例如,当按下 F3 时git commit -a -m "test"应该执行。

Thr*_*iag 7

map <F3> :!git commit -a -m "test" <enter>
Run Code Online (Sandbox Code Playgroud)

在其他答案的基础上,这消除了多余的调用sh并启动命令,而无需按 Enter。

我正在寻找这个但找不到,我也无法发表评论,所以我做了一个答案。


xan*_*eng 6

尝试map <F3> :!sh -xc 'git commit -a -m "test"'

  • 为什么要费心去执行 `sh` 而不仅仅是 `:!git commit -am "test"` 呢? (7认同)