在vim中向右移动两次



我正试图进入Vim并重新映射密钥等等,但我偶然发现了一个奇怪的问题。我把hjkl重新映射到了jkl;因为这对我来说更直观,但现在每当我按下;它向右移动了两次。我不确定我是否真的介意,因为这抵消了我的小指比其他手指弱的事实,但如果维姆忍者不介意通读这篇文章,我真的很想知道为什么会发生这种情况。

这是我的.virc(底部标记为Jae的Vim设置,摘录自我教授的一个Vim设置):

" jj => esc
:imap jj <Esc>
"remap navigation keys
:nnoremap ; l 
:nnoremap l k
:nnoremap k j
:nnoremap j h
" highlight search
set hlsearch
"left-to-right wrapping
set whichwrap+=<,>,h,l,[,]
"Jae's Vim settings
"
" Line numbers
set number
" Syntax
syntax on
execute pathogen#infect()
filetype plugin indent on
" Buffer switching using Cmd-arrows in Mac and Alt-arrows in Linux
:nnoremap <D-Right> :bnext<CR>
:nnoremap <M-Right> :bnext<CR>
:nnoremap <D-Left> :bprevious<CR>
:nnoremap <M-Left> :bprevious<CR>
" and don't let MacVim remap them
if has("gui_macvim")
   let macvim_skip_cmd_opt_movement = 1
endif
" When coding, auto-indent by 4 spaces, just like in K&R
" Note that this does NOT change tab into 4 spaces
" You can do that with "set tabstop=4", which is a BAD idea
set shiftwidth=4
" Always replace tab with 8 spaces, except for makefiles
set expandtab
autocmd FileType make setlocal noexpandtab
" My settings when editing *.txt files
"   - automatically indent lines according to previous lines
"   - replace tab with 8 spaces
"   - when I hit tab key, move 2 spaces instead of 8
"   - wrap text if I go longer than 76 columns
"   - check spelling
autocmd FileType text setlocal autoindent expandtab softtabstop=2 textwidth=76 spell spelllang=en_us
" Don't do spell-checking on Vim help files
autocmd FileType help setlocal nospell
" Prepend ~/.backup to backupdir so that Vim will look for that directory
" before littering the current dir with backups.
" You need to do "mkdir ~/.backup" for this to work.
set backupdir^=~/.backup
" Also use ~/.backup for swap files. The trailing // tells Vim to incorporate
" full path into swap file names.
set dir^=~/.backup//
" Ignore case when searching
" - override this setting by tacking on c or C to your search term to make
"   your search always case-insensitive or case-sensitive, respectively.
set ignorecase
"
" End of Jae's Vim settings

问题是因为映射错误。您当前有

nnoremap ; l<space>

末端的额外空间被视为映射的一部分。由于默认情况下<space>向右移动,因此会导致移动两个空格。去掉多余的空间,它应该可以正常工作。

最新更新