Git Product home page Git Product logo

better-escape.vim's Introduction

๐Ÿ’ก 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 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: use {'jdhao/better-escape.vim', event = 'InsertEnter'}
  • vim-plug: Plug 'jdhao/better-escape.vim'
  • dein: call dein#add('jdhao/better-escape.vim')
  • vim-packager: call packager#add('jdhao/better-escape.vim')
  • 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:

" 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:

" 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:

# 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:

" 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.

๐Ÿ“ License

This plugin is released under the MIT License.

โค๏ธ Similar projects

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.