在Vim中映射键,意外行为

时间:2016-03-14 14:10:36

标签: vim

在Vim中,键k将光标向上移动一行。如果我将键e映射到键knoremap e k,那么当我按下e时,光标会向上移动一行一个位置到对。为什么会这样?是否有一些Vim插件干扰了noremap或者我遗漏了什么?如何调试?

我的.vimrc文件:

" Use spaces instead of tabs
set expandtab

" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4

" Set vim to be noncompatible with vi.
" There is no funky behavior with arrow keys this way.
set nocompatible

" Configure backspace so it acts as it should act
set backspace=indent,eol,start

" Solarized color scheme
syntax enable
colorscheme SolarizedDarkCinnamon

" Underline the cursor line.
set cursorline
hi CursorLine term=bold cterm=bold 

" allow to copy from and to clipboard
set clipboard=unnamedplus

" Set autoindentation
set autoindent

" Uncomment the following to have Vim jump to the last position when                                                       
" reopening a file
if has("autocmd")
  au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
    \| exe "normal! g'\"" | endif
endif

let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_autoclose_preview_window_after_insertion = 1

set iminsert=0
set imsearch=0

1 个答案:

答案 0 :(得分:2)

我的猜测是你的映射定义中有一个尾随空格。删除它。