ashim
ashim

Reputation: 25580

Mapping keys in Vim, unexpected behavior

In Vim, key k moves the cursor one line up. If I map key e to key k: noremap e k, then when I press e the cursor moves one line up and one position to the right. Why does it happen? Is it some Vim plugin interferes with noremap or I am missing something? How to debug it?

My .vimrc file:

" 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

Upvotes: 1

Views: 106

Answers (1)

Luc Hermitte
Luc Hermitte

Reputation: 32966

My guess is that you have a trailing whitespace in your mapping definition. Remove it.

Upvotes: 2

Related Questions