我有以下vimrc文件
map u <Up>
map n <Left>
map e <Down>
map i <Right>
noremap h i
noremap t w
noremap s b
用dt
或ct
删除或更改单词工作,但当我想用dht
或cht
删除内部单词时,它不工作,但dhw
或chw
工作。我在重新绘制的琴键中漏掉了什么吗?
我试过用map代替noreamp,但是没有用。
Vim的操作符挂起模式可能不期望单个字符的两个连续映射。但是你可以做一个多字符映射。
noremap ht iw
noremap at aw
这将允许您执行dht
,dat
,cht
和cat
,以及vht
和vat
。
对于多字符映射,请注意'timeoutlen'
选项设置。通常默认为1000ms。如果您有h
和ht
的映射,那么这将减慢您的h
映射,因为Vim必须等待多达1000ms才能键入t
。您可以将'timeoutlen'
缩短到更短的时间,但它必须足够长,以便您可以同时键入h
和t
。
noremap
命令适用于Normal、Visual和Operator-Pending模式。
你可能想只指定Operator-Pending和Visual模式,而排除Normal模式,这样你就不会减慢其他Normal模式映射的速度。
onoremap ht iw
onoremap at aw
vnoremap ht iw
vnoremap at aw