一千萬個為什麽

搜索

在正常模式下禁用Ctrl-Z

如果我在正常模式下按 Ctrl z ,它會使我的gVim“最小化”或在vim(不是gVim)中返回shell。

我想禁用此功能但是

  • I can't unmap Ctrlz: unmap returns no such mapping
  • There is no option called suspend, allowing me to use unset suspend.

我做了:help suspend 但該文檔沒有提到任何關於禁用“suspend”的內容。

最佳答案

因此,您需要了解以下幾點:

Firstly you can't use :unset suspend and that is normal. Suspending Vim is not controlled by and option (that you could unset) but by a command: :suspend. See :h :suspend

Secondly you want to disable the suspension triggered by ctrlz. This is a built-in command, thus you can not "unmap" this key combination. The only mappings that you can unmap are the one that you (or a plugin) created with a command :map .

你可以做的是對Vim說“當我按 ctrl z 什麽都不做,而不是像往常那樣暫停”。

這是這個命令的作用:

nnoremap  

你可以這樣理解:

n                      Do the following mapping only in normal mode
 nore                  Don't make it recursive (This is not necessary here but strongly recommended in all your mappings)
     map               Create a mapping
                  The keys that you want to remap
                  This is the short for "no operation" i.e. Do nothing

You can add the line to your vimrc or simply type in vim's command line :nnoremap so that the mapping will only exists in the current session.

See :h .

轉載註明原文: 在正常模式下禁用Ctrl-Z