tl;dr: Any ideas on how to have the esc key map to :noh and the mouse=a working, but at the same time without breaking vim completely?
I added the following lines to my .vimrc file:
nnoremap <esc> :noh<return><esc>
as suggested by:
though, I have the following also on:
:set mouse=a
I am not sure why but now whenever I start vim, it starts by trying to do a :noh command without me telling it. Furthermore, if I try clicking on my vim screen it just decides to replace everything from line 1 to wherever I clicked with an empty space. I am also in insert mode automatically after the click. Even after get out of it and start trying to edit normally, the mouse click is completely messed up, I'm not even sure what its doing.
I am using iTerm2 in mac OS X. I am also using the z shell and oh-my-zsh.
Here is how my .vimrc file looks like:
"
""disabiling arrows
"
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
" ---
filetype off
call pathogen#infect()
call pathogen#helptags()
let g:gofmt_command = 'goimports'
autocmd BufWritePre *.go Fmt
" ---
:syntax on
:set mouse=a
:set nu
:set hlsearch
nnoremap <esc> :noh<return><esc>
"
filetype off
filetype plugin indent off
set runtimepath+=$GOROOT/misc/vim
filetype plugin indent on
syntax on
"
Any ideas on how to have the esc key map to :noh and the mouse=a working, but at the same time without breaking vim completely?
A possible solution might be to map :noh to some other key or sequence of keys that are safer. I am not sure which one might be a good idea, but if someone has one that makes sense, I would be happy to hear suggestions!