简体   繁体   English

vim映射的噩梦

[英]vim mappings nightmare

I am using MacVim and I am trying to change the basic default key mappings, but I am failing miserably. 我正在使用MacVim,并且尝试更改基本的默认键映射,但是我失败了。 I dont know why it's so complicated. 我不知道为什么这么复杂。 This is what I am trying to do: (please tell me what to put in my .gvimrc) 这就是我想要做的:(请告诉我在.gvimrc中放入什么)

  • remap Home to ^ (use in imode and end up in imode as well) 重映射Home到^(在imode中使用,并在imode中也结束)
  • remap End to $ (use in imode and end up in imode as well) 将End重新映射为$(在imode中使用,并在imode中也终止)
  • remap Shift+anyArrowKey to the usual select things (use in imode and end up in imode as well) 将Shift + anyArrowKey重新映射为常用的选择对象(在imode中使用,并在imode中也结束)

Basically, I am trying to get usual edit functionality to macvim. 基本上,我正在尝试使macvim具有通常的编辑功能。

Keep in mind that some kind of unmappings need to happen first. 请记住,首先需要进行某种类型的映射。 I already tried just adding mappings, but it doesnt work. 我已经尝试过仅添加映射,但是它不起作用。

If you could paste a section that I could just copy/paste to my .gvimrc file, that would be great. 如果您可以粘贴一个我可以复制/粘贴到.gvimrc文件中的部分,那就太好了。

This is how my mappings look like: (from running :map) 这就是我的映射的样子:(从运行:map开始)

 n  gx            <Plug>NetrwBrowseX
       <M-Down>      }
       <D-Down>    * <C-End>
       <M-Up>        {
       <D-Up>      * <C-Home>
       <M-Right>   * <C-Right>
       <D-Right>   * <End>
       <M-Left>    * <C-Left>
       <D-Left>    * <Home>
    n  <Plug>NetrwBrowseX * :call netrw#NetrwBrowseX(expand("<cWORD>"),0)<CR>
    v  <BS>          "-d
    v  <D-x>         "*d
    v  <D-c>         "*y
    v  <D-v>         "-d"*P
    n  <D-v>         "*P

You shouldn't do that and learn Vim instead: while what you want is very easy to do, it's also a very very bad idea . 您不应该这样做,而应该学习Vim:尽管您想要的东西很容易做到,但这也是一个非常非常糟糕的主意

Vim draws a large part of its power from a strict separation between what can/should be done in insert mode (inserting text) and what can/should be done in normal mode (navigation, yanking, pasting, deleting…). Vim严格分隔了插入模式(插入文本)可以/应该做什么和普通模式(导航,拉动,粘贴,删除...)之间可以/应该做什么之间的严格分离,从而吸收了很大一部分力量。 Modal editing can be weird in the beginning but you'll get used to it soon and swear by it later. 模态编辑一开始可能很奇怪,但是您很快就会习惯它,以后会发誓。 It's only a matter of time. 这只是时间问题。

I've done exactly what you ask and more (tried to change all Vim mappings to TM ones) when I switched from TextMate until I realized it was the most counter-productive thing to do. 当我从TextMate切换到我意识到这是最适得其反的事情时,我已经完全按照您的要求做了(尝试将所有Vim映射更改为TM)。

If you really don't like (or don't want to adjust to) modal editing, there are many text editors out there which will let you use your keyboard "normally" and have lots of powerful features. 如果您真的不喜欢(或不想适应)模式编辑,那么那里有很多文本编辑器,这些编辑器可以让您“正常”使用键盘具有许多强大的功能。

That said, here are some pointers: 也就是说,这里有一些指针:

:h key-notation
:h mapping

and you don't need any unmappings. 而且您不需要任何映射。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM