Every time I type Shift+Space in vim, it undoes all changes to the file that have not yet been written. I would like this to not happen, as it is extremely easy to press Shift+Space by accident.

I am using iTerm2, and am ssh'ed into a remote machine. When I use vim (in iTerm2) on my local (OSX) machine, this issue does not occur. When I use the default terminal instead of iTerm2, this does not occur, even when ssh'ed into the same system. So: only the combination of iTerm2 + being in an ssh session seems to cause problems.

I have never modified any vim keybindings; I have no ~/.vimrc, and :verbose Map <S-Space> doesn't show any binding. This makes me think this is an iTerm2 issue - but I don't understand why it would not cause this problem when running a shell on my local machine. Are there any iTerm2 profile settings that apply only in ssh? Or should I look elsewhere for this issue?

  • 1
    It's not clear from your question: if you are not running in tmux or iTerm2, does the Shift-Space keystroke still wipe your changes?
    – Sotto Voce
    Sep 14, 2023 at 21:47
  • On macOS, in Vim within tmux, running in iTerm2, I can not reproduce this behaviour. Nothing binds Shift+Space out of these applications, nor does the macOS GUI as far as I can tell.
    – Kusalananda
    Sep 14, 2023 at 22:04
  • have you check ~/.vimrc for some previous :map?
    – JJoao
    Sep 14, 2023 at 22:37
  • Even without tmux, this happens. However, it only appears to happen in vim when I am running on another system I have ssh'ed to - it does not happen in vim on my local machine. I have no ~/.vimrc file, so unless there is somewhere mappings can be stored, I'm not sure. Fortunately, I was wrong about the changes being discarded - they can be redone, I just have to hit ^r several times (I guess the undo buffer, if that's the right term, gets some empty changes in it that I have to redo past in order to actually redo my edits.)
    – Peter
    Sep 15, 2023 at 23:15
  • Do you have a custom Vim setup on the remote machine? You say "I have no ~/.vimrc" but it's unclear what system your are referring to (the local or the remote).
    – Kusalananda
    Sep 16, 2023 at 9:48

1 Answer 1


Got it - the problem was the iTerm2 setting "Report modifiers using CSI u", as described here. Disabling that fixed the issue.

I thought this might be the problem and disabled it before, but it seems that it only takes effect on restarting iTerm2 (or perhaps closing the session), so I mistakenly excluded that as the culprit.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .