首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >向右移动两次?

向右移动两次?
EN

Stack Overflow用户
提问于 2014-08-28 15:58:46
回答 1查看 156关注 0票数 0

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

这是我的.vimrc (下面的部分是Jae的Vim设置,摘自我教授的vim设置之一):

代码语言:javascript
复制
" 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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-08-28 16:25:55

问题在于你的映射是错误的。你现在

nnoremap ; l<space>

最后的额外空间被视为映射的一部分。由于<space>在默认情况下是向右移动的,这将导致移动两个空格。去掉多余的空间,它就能正常工作了。

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25553170

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档