Ⅰ. 插件描述
vim-easyescape makes exiting insert mode easy and distraction free!Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'zhou13/vim-easyescape'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'zhou13/vim-easyescape'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'zhou13/vim-easyescape'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/zhou13/vim-easyescape
Ⅳ. 文档说明
# vim-easyescape
_____ _____
| ____|__ _ ___ _ _ | ____|___ ___ __ _ _ __ ___
| _| / _` / __| | | | | _| / __|/ __/ _` | '_ \ / _ \
| |__| (_| \__ \ |_| | | |___\__ \ (_| (_| | |_) | __/
|_____\__,_|___/\__, | |_____|___/\___\__,_| .__/ \___|
|___/ |_|Pull out your Escape key!
<ESC>/<C-[>/<C-C> is hard to press? Try vim-easyescape! vim-easyescape makes exiting insert mode easy and distraction free.
Problems
Traditionally, we need to use
inoremap jk <Esc>
inoremap kj <Esc>or
inoremap jj <Esc>so that we can press jk simultaneously (in arbitrary order since we have two maps) or press j twice to exit the insert mode. However, a problem with such map sequence is that Vim will pause whenever you type j or k in insert mode (it is waiting for the next key to determine whether to apply the mapping). The pause causes visual distraction which you may or may not notice.
vim-easyescape does not have such problem and supports custom timeout.
Installation
Use your favourite plugin manager, e.g., vim-plug:
Plug "zhou13/vim-easyescape"Usage
Configuration 1: map of jk and kj (recommended)
The unit of timeout is in ms. A very small timeout makes an input of real jk or kj possible (Python3 is required for this feature)!
let g:easyescape_chars = { "j": 1, "k": 1 }
let g:easyescape_timeout = 100
cnoremap jk <ESC>
cnoremap kj <ESC>Configuration 2: map of jj
let g:easyescape_chars = { "j": 2 }
let g:easyescape_timeout = 100
cnoremap jj <ESC>Dependency
Python3 is required if timeout (g:easyescape_timeout) is less than 2000 ms because vim does not provide a way to fetch sub-second time.
Known problems
- Maps of keys in
g:easyescape_charsneed to be created. - Does not work in command/visual mode due to lack of
InsertCharPrein vim/nvim.