繁体   English   中英

<leader>键+“ w”映射在执行之前会延迟几秒钟?

[英]<leader> key + “w” mapping delays for a few seconds before executing?

我使用以下方法使保存更快地在Vim中进行:

nnoremap <leader>w :w!<cr>
inoremap <leader>w <esc>:w!<cr>

但是,第一个发生一些奇怪的事情,每次我保存时,都会有2秒的延迟。 我认为这很奇怪,因为将其设置为nnoremap并且没有指向w另一个映射。

可能是什么问题呢?

我的.virmc

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Maintainer: Alexandro Chen
" Website:    http://alexandrochen.com
" Version:    0.1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Basic
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" Sets how many lines of history VIM has to remember
set history=700

filetype plugin on
filetype indent on

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Appareance
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
syntax enable

colorscheme molokai
set guifont=Droid\ Sans\ Mono\ 10

set encoding=utf8

set number
set ruler

set magic
set nolazyredraw
set showmatch

" Sets initial window size
set lines=40 columns=160

set softtabstop=2
set shiftwidth=2
set tabstop=2
set expandtab

set guioptions-=r " Disable right scrollbar
set guioptions-=R
set guioptions-=l " Disable left scrollbar
set guioptions-=L
set t_Co=256

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Mapping
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let mapleader = ","

nnoremap <leader>w :w!<cr>
inoremap <leader>w <esc>:w!<cr>

nnoremap <leader>sv :source $MYVIMRC<cr>
nnoremap <leader>ev :split $MYVIMRC<cr>

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Files
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nobackup
set nowb
set noswapfile

autocmd FileType ruby,coffeescript autocmd BufWritePre <buffer> :%s/\s\+$//e

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Workarounds
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:session_autoload = 'no'

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugins
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" NERDTree
au VimEnter * NERDTree /home/alex/

" Zen Coding
let g:user_zen_expandabbr_key = '<leader>e'

我认为您最好删除inoremap <leader>w <esc>:w!<cr>并添加inoremap jk <esc> ,每次要保存文件时,最好返回普通模式并保存。当您按,word ,vim将以,w保存文件。

因此,当您注释掉

inoremap <leader>w <esc>:w!<cr>

您还是第一个有问题吗?

另外, :help ttimeoutlen

'ttimeoutlen' 'ttm' number  (default -1)
  The time in milliseconds that is waited for a key code or mapped 
  key sequence to complete.

我在我的.vimrc文件中set ttimeoutlen=10

另外,我玩了一段时间的保存映射,最后将保存映射到space键上。 很高兴。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM