In vim how to map “save” to ctrl-s

前端 未结 4 991
伪装坚强ぢ
伪装坚强ぢ 2020-12-07 15:32

In vim, how can I map \"save\" (:w) to ctrl-s.

I am trying \"map\" the command, but xterm freezes when I press ctrl-

4条回答
  •  温柔的废话
    2020-12-07 15:59

    Mac OSX Terminal + zsh?

    In your .zprofile

    alias vim="stty stop '' -ixoff; vim"
    

    Why?, What's happening? See Here, but basically for most terminals ctrl+s is already used for something, so this alias vim so that before we run vim we turn off that mapping.

    In your .vimrc

    nmap  :w
    imap  :wa
    

    Why? What's happening? This one should be pretty obvious, we're just mapping ctrl+s to different keystrokes depending on if we are in normal mode or insert mode.

提交回复
热议问题