在 vim 中将命令 s 映射到 :w [英] Mapping command s to :w in vim

查看:36
本文介绍了在 vim 中将命令 s 映射到 :w的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在vim中将Command S映射到:w?

我已经尝试了其他线程中的所有内容,但在 Mac OS X El Capitan 中似乎没有任何效果.

这应该在以前的版本中有效,但我试过了,没有成功.

noremap <无声><C-S>:更新<CR>vnoremap <silent><C-S><C-C>:更新<CR>inoremap <无声><C-S><C-O>:更新<CR>

我能找到的关于这个主题的所有东西都已经有好几年了,不再有效.我可以找到

仅供参考,0x1120x113 等等.我的 的选择是任意的,使用适合你的任何东西.

在 Terminal.app...

我没有 El Capitan,所以我不知道可以在新的 Terminal.app 中做什么,但它以前的化身不允许您重新映射任意键——只有一个预定义的集合——所以我不知道认为它在没有假设的第三方工具的情况下在这里是可行的.

  • 在 Vim 中使用 Cmd+S 的整个想法非常糟糕.而是习惯于 Vim 方式.

  • How can I map Command S to :w in vim?

    I have tried everything from other threads but nothings seems to work in Mac OS X El Capitan.

    This supposedly worked in previous versions, but I tried it, and had no success.

    noremap  <silent> <C-S>    :update<CR>
    vnoremap <silent> <C-S>    <C-C>:update<CR>
    inoremap <silent> <C-S>    <C-O>:update<CR>
    

    Everything on this topic that I could find is several years old and doesn't work anymore. I could find this thread or this thread, but they are both more than three years old and no longer work. That is why I am asking for the current version of Mac OS X (El Capitan)

    解决方案

    1. <C- is the notation for the Control key. It's <D- for the Command key.

    2. The Command key is only visible to MacVim and only when using the GUI front end. No matter what Vim you use in Terminal.app or iTerm.app (MacVim or any other build), it will never see the command key.

      In other words, you can't expect <D- mappings to work in CLI Vim. It is simply impossible.

    3. The only way to get CLI Vim to do anything upon pressing Cmd+something on Mac OS X is to map that combo in your terminal emulator to emulate pressing on another key, itself mapped to the desired command in Vim.

      In ~/.vimrc

      nnoremap <F6> :w<CR>
      

      In iTerm.app…

      FYI, 0x112 is <F1>, 0x113 is <F2>, etc. My choice of <F6> is arbitrary, use whatever works for you.

      In Terminal.app…

      I don't have El Capitan so I have no idea of what can be done in the new Terminal.app but its previous incarnations didn't allow you to remap arbitrary keys — only a predefined set — so I don't think it's doable here without some hypothetical third-party tool.

    4. The whole idea of using Cmd+S in Vim is very bad. Get used to the Vim way instead.

    这篇关于在 vim 中将命令 s 映射到 :w的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆