7

If I press Ctrlz in normal mode, it makes my gVim "minimized" or in vim (not gVim ) it goes back to the shell.

I want to disable this feature but

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

I did :help suspend but the document doesn't mention anything about disabling "suspend".

10

So there are several things that you need to understand:

Firstly you can't use :unset suspend and that is normal. Suspending Vim is not controlled by an 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 <key> <action>.

What you can do is to say to Vim "When I press ctrlz do nothing instead of suspending as you usually do".

This is what this command does:

nnoremap <c-z> <nop>

You can understand it like this:

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
         <c-z>         The keys that you want to remap
               <nop>   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 <c-z> <nop> so that the mapping will only exists in the current session.

See :h <nop>.

  • I was using neovim on windows with cmder, habit of ctrl+z'ing made neovim suspend itself but since there is no job control, I wasn't able to get back into neovim. Hence every time this is triggered I had to kill the process. Unmapping suspend did the trick! – Steven Huang Nov 14 '18 at 9:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.