Reputation: 13
So this is a part of my .vimrc
" Mapping
nnoremap <F3> :cclose<cr>
nnoremap <F4> :w <bar> !cd ../build; make<cr><cr>:cw<cr>
autocmd filetype cpp nnoremap <F6> :Termdebug %:r<CR><c-w>2j<c-w>L
nnoremap <F12> :!cd ..; !ctags -R
"nnoremap <C-[> :psearch <C-R><C-W><CR>
nnoremap <C-H> <C-W>h
nnoremap <C-J> <C-W>j
nnoremap <C-K> <C-W>k
nnoremap <C-L> <C-W>l
inoremap <C-H> <Left>
inoremap <C-J> <Down>
inoremap <C-K> <Up>
inoremap <C-L> <Right>
nnoremap <esc><esc> :silent! noh<cr>
inoremap " ""<left>
inoremap ' ''<left>
inoremap ( ()<left>
inoremap [ []<left>
inoremap { {}<left>
inoremap {<CR> {<CR>}<ESC>O
inoremap {;<CR> {<CR>};<ESC>O
As you can see I have a line commented, which I think is giving me some problems. When that is not commented and I open vim this is what I got:
A preview windows of the actual file is opened and I get into replace mode, also there are more weird behaviour, for example if I am in insert mode and I press <Esc><Esc>
and press some arrow key vim insert a D or an U (as you can imagine depend on which key I press)
Upvotes: 1
Views: 49
Reputation: 195209
You got this problem because <C-[>
has the same keycode as ESC
.
:h keycodes
then you search for "esc", you will find both have keycode 27. That is, you mapped ctrl-[
, in fact, you mapped ESC
.
In INSERT mode, when you pressed ESC twice, the first ESC brings you back to NORMAL mode, and the 2nd ESC triggers your mapping, the :psearch
command.
Also when you press ESC in normal mode, the mapping is gonna be triggered as well.
The solution is also easy, don't map <C-[>
.
Upvotes: 1