Vim键映射在命令编辑器中工作,而不是在.vimrc中 - 为什么?

时间:2014-02-28 22:06:58

标签: vim

当我通过命令缓冲区创建以下键映射时,它按预期工作,将光标向下移动5行:

map ^[[1;3B 5<Down>

当我将它添加到我的.vimrc文件以便它可以跨会话时,按Alt +向下移动1行(到不在垂直上方的某个地方 - 也许它会转到上一个句子)。我的:地图输出是这样的:

0             ^
^[[1;3B       5<Down>
n  gx         <Plug>NetrwBrowseX
n  <Plug>NetrwBrowseX * :call netrw#NetrwBrowseX(expand("<cWORD>"),0)<CR>

Press ENTER or type command to continue

为什么这个vimrc映射的工作方式与我在命令缓冲区中输入的内容类似?

我的vim版本是:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 10 2014 00:22:49)
Included patches: 1-135
Compiled by <cygwin@cygwin.com>

更新

有两个问题。

  1. 我的Vim版本不理解map <M-Down> 5<Down>但理解map <M-Down> 5j
  2. 我的.vimrc文件中的某些内容会阻止map <M-Down> 5j工作。我必须在我的Cygwin环境中放入一堆黑客来获得“正常”的vim行为:
  3. "==================
    " Keyboard trouble
    "=================
    
    " Every so often I am using a system that inserts a A, B, C, or D
    " when using the arrow keys within the Vim editors insert mode.
    " Vim is for VI Improved. While I did not dig into the exact reasons
    " as to why (terminal emulation?) it happens, it is quite annoying.
    set nocompatible
    "set term=cons25
    
    " This fixes Cygwin's vim's page up, home, end etc. keys
    " http://superuser.com/questions/480215/
    " how-to-map-pagedown-and-pageup-keys-to-function-normally
    set term=mintty
    set backspace=2 " backspace on Cygwin Windows Objy was not deleting properly. 
    " But this doesn't solve other cursor movements like
    "home and end
    "source /home/sarnobat/.vim/cscope_maps.vim
    "g:CCTreeCscopeDb = "/home/sarnobat/cscope/cscope.files"
    
    "==============================
    " Key bindings
    "==============================
    map 0 ^
    

2 个答案:

答案 0 :(得分:0)

我不明白这些角色:^[[1;3B。在中,您可以选择Alt键作为字母M,将箭头字母选为down,这样:

map <M-down> 5<Down>

可以在命令行和vimrc文件中使用。

答案 1 :(得分:0)

你可以尝试以下方法:

map <M-down> 5j

在cygwin上尝试过它并且有效。 hjkl是向左,向下,向上和向右导航的首选方法。