Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nvim-zh/better-escape.vim
A Vim/Neovim plugin for escaping insert mode without lagging.
https://github.com/nvim-zh/better-escape.vim
esc neovim neovim-plugin nvim nvim-plugin plugins vim vim-plugin vim-plugins
Last synced: 28 days ago
JSON representation
A Vim/Neovim plugin for escaping insert mode without lagging.
- Host: GitHub
- URL: https://github.com/nvim-zh/better-escape.vim
- Owner: nvim-zh
- License: mit
- Created: 2020-12-15T17:26:26.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-02-05T16:00:04.000Z (over 2 years ago)
- Last Synced: 2024-02-24T11:54:32.449Z (4 months ago)
- Topics: esc, neovim, neovim-plugin, nvim, nvim-plugin, plugins, vim, vim-plugin, vim-plugins
- Language: Vim script
- Homepage:
- Size: 28.3 KB
- Stars: 160
- Watchers: 2
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-stars - nvim-zh/better-escape.vim - A Vim/Neovim plugin for escaping insert mode without lagging. (Vim Script)
README
# ๐ก Motivation
A lot of people have been mapping `jk` or `kj` or `kk` to ESC in
order to escape insert mode quickly. However, when we press the first key in
these mappings, Vim/Nvim will wait for [`timeoutlen`](https://neovim.io/doc/user/options.html#'timeoutlen')
milliseconds before writing this char to buffer. The apparent lag caused by
this behaviour is annoying.Better-escape.vim is created to help Vim/Nvim users escape insert mode quickly
using their customized key combinations, **without experiencing the lag**.# ๐ Quickstart
## Requirements
+ Neovim: 0.4.4 and above
+ Vim: 8.0 and above (not tested on Vim 7.4)## Install
Use your favorite plugin manager to install it:
+ [packer.nvim](https://github.com/wbthomason/packer.nvim): `use {'jdhao/better-escape.vim', event = 'InsertEnter'}`
+ [vim-plug](https://github.com/junegunn/vim-plug): `Plug 'jdhao/better-escape.vim'`
+ [dein](https://github.com/Shougo/dein.vim): `call dein#add('jdhao/better-escape.vim')`
+ [vim-packager](https://github.com/kristijanhusak/vim-packager): `call packager#add('jdhao/better-escape.vim')`
+ [minpac](https://github.com/k-takata/minpac): `call minpac#add('jdhao/better-escape.vim')`## How to use?
This plugin works out of the box. The default shortcut for escaping insert mode
is `jk`, that is, pressing `j` first, then pressing `k` **quickly**, you will
leave insert mode.# ๐ง Configuration
## How to change shortcut
If you want to use other shortcuts, you can customize via option `g:better_escape_shortcut`:
```vim
" use jj to escape insert mode.
let g:better_escape_shortcut = 'jj'
```## Adjust time interval threshold
By default, the time interval threshold between pressing `j` and `k` is 150 ms.
That is, if the time interval between pressing `k` and `j` is above the
threshold, `jk` will be inserted literally. Otherwise, we assume you want to
leave insert mode. The threshold can be customized via option `g:better_escape_interval`:```vim
" set time interval to 200 ms
let g:better_escape_interval = 200
```## Using multiple shortcuts?
Some people may prefer to use multiple shortcuts. This is also supported:
```vim
# non-ASCII shortcuts are also supported for non-English keyboard.
let g:better_escape_shortcut = ['jk', 'jj', 'kj', 'ะปะป']
```## Debug and choose suitable interval
Sometimes, you may wonder why the given escape shortcut does not work as intended.
Maybe it is because you have not pressed the two keys fast enough.
To get the interval between key presses and help you to set a reasonable interval,
use the option `g:better_escape_debug`:```vim
" enable debug (some message will be shown)
let g:better_escape_debug = 1
```Then run command `:messages` to check the debug log.
# ๐ Documentation
See [`:h better-escape.txt`](doc/better-escape.txt).
# ๐ License
This plugin is released under the MIT License.
# โค๏ธ Similar projects
+ https://github.com/Krafi2/jeskape.nvim
+ https://github.com/zhou13/vim-easyescape
+ https://github.com/max397574/better-escape.nvim (a lua re-implementation of this plugin)