wyc
wyc

Reputation: 55273

<leader> key + "w" mapping delays for a few seconds before executing?

I used the following to make saving saving faster in Vim:

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

Something strange happens with the first one, though, each time I save there is like a 2-second delay. I think this is strange since it is set as nnoremap and there isn't another mapping pointing to w.

What could be the problem?

My .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'

Upvotes: 1

Views: 1022

Answers (2)

vrybas
vrybas

Reputation: 1719

So, when you comment out

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

you still have a problem with the first one?

Also, :help ttimeoutlen

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

I have set ttimeoutlen=10 in my .vimrc

Also, I've played with save mappings for a while, and finally mapped save on space bar. Very happy with it.

Upvotes: 2

xautjzd
xautjzd

Reputation: 309

I think you had better to remove the inoremap <leader>w <esc>:w!<cr>, and add inoremap jk <esc>,everytime you want to save file, you had better to return normal mode and save it.Or when you press ,word, vim will regard ,w to save file.

Upvotes: 1

Related Questions