[英]What is wrong with this mapping? Vim starts in — REPLACE — mode
自从我上次更新它以来,我的.vimrc
有一个奇怪的错误。
每次我启动vim它都会以-- REPLACE --
模式开始,这真的很烦人。
我设法发现我的.vimrc
中的这一行导致了问题。
" Disable search highlighting temporally
nnoremap <esc> :nohl<cr>
当我评论这条线时,问题就消失了。
我对绘图的错误感到困惑。 它可以正常工作,但会导致vim在启动时进入-- REPLACE --
模式。
我目前根本没有启用插件。
最好避免映射Esc键,因为它已知会导致奇怪的行为:
我一直在使用<leader><space>
来禁用突出显示,正如“回到Vim回家”所建议的那样,也许你也可以习惯它。
我有同样的问题,虽然它是在tmux里面,当我开始vi(又名vim)时,它会以REPLACE模式启动。 罪魁祸首似乎是我一直在使用的TERM的TERMCAP定义:xterm-256color。
一旦我将TERM设置为不同的东西,vi(vim)就能正常工作。 即使是“ansi”的TERM设置也表现得更好。
我选择了“screen-256color-s”的TERM设置,可以根据需要使用。
有趣的TERMCAP定义。
通过将以下内容附加到我的vimrc
文件中,我已经能够解决同样的问题:
" Terminal fixes
"
" These originate from some linux distribution's system vimrc. I can't say
" that I understand the details what's going on here, but without these
" settings, I've had problems like vim starting in REPLACE mode for
" TERM=xterm-256color (neovim is fine)
if &term =~? 'xterm'
let s:myterm = 'xterm'
else
let s:myterm = &term
endif
let s:myterm = substitute(s:myterm, 'cons[0-9][0-9].*$', 'linux', '')
let s:myterm = substitute(s:myterm, 'vt1[0-9][0-9].*$', 'vt100', '')
let s:myterm = substitute(s:myterm, 'vt2[0-9][0-9].*$', 'vt220', '')
let s:myterm = substitute(s:myterm, '\\([^-]*\\)[_-].*$', '\\1', '')
" Here we define the keys of the NumLock in keyboard transmit mode of xterm
" which misses or hasn't activated Alt/NumLock Modifiers. Often not defined
" within termcap/terminfo and we should map the character printed on the keys.
if s:myterm ==? 'xterm' || s:myterm ==? 'kvt' || s:myterm ==? 'gnome'
" keys in insert/command mode.
map! <ESC>Oo :
map! <ESC>Oj *
map! <ESC>Om -
map! <ESC>Ok +
map! <ESC>Ol ,
map! <ESC>OM
map! <ESC>Ow 7
map! <ESC>Ox 8
map! <ESC>Oy 9
map! <ESC>Ot 4
map! <ESC>Ou 5
map! <ESC>Ov 6
map! <ESC>Oq 1
map! <ESC>Or 2
map! <ESC>Os 3
map! <ESC>Op 0
map! <ESC>On .
" keys in normal mode
map <ESC>Oo :
map <ESC>Oj *
map <ESC>Om -
map <ESC>Ok +
map <ESC>Ol ,
map <ESC>OM
map <ESC>Ow 7
map <ESC>Ox 8
map <ESC>Oy 9
map <ESC>Ot 4
map <ESC>Ou 5
map <ESC>Ov 6
map <ESC>Oq 1
map <ESC>Or 2
map <ESC>Os 3
map <ESC>Op 0
map <ESC>On .
endif
在https://gist.github.com/goerz/36015f27c2a5423c64a5f9dc03865f2c中有更多类似的设置,这可能也有帮助。 根本原因是在termcap / terminfo中不正确
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.