在vim中向右移动两次?

时间:2014-08-28 15:58:47

标签: vim

我正试图进入Vim并重新映射键和诸如此类的东西,我偶然发现了一个奇怪的问题。我已经将hjkl重新映射到jkl;因为这对我来说更直观,但现在每当我按下;它向右移动了两次。不确定我真的介意它,因为它抵消了我的小指比我的其他手指弱的事实,但如果一个Vim忍者不介意阅读这个,我真的想知道为什么会发生这种情况。

这是我的.vimrc(底部,标记为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

1 个答案:

答案 0 :(得分:6)

问题是因为您的映射是错误的。你目前有

nnoremap ; l<space>

最后的额外空间被视为映射的一部分。由于<space>默认情况下向右移动,因此会移动两个空格。删除多余的空间,它应该工作正常。

相关问题