nvim-zh / better-escape.vim Goto Github PK
View Code? Open in Web Editor NEWA Vim/Neovim plugin for escaping insert mode without lagging.
License: MIT License
A Vim/Neovim plugin for escaping insert mode without lagging.
License: MIT License
First of all, thank you for your plugin!
The part I most appreciate is that it is written in VimL (making it not python3 dependent and backwards compatible)
I will love to see this plugin working on vim/nvim built in terminal.
This is not good enough, I need short interval (which this plugin provides)
tmap jk <c-\><c-n>
tmap kj <c-\><c-n>
Thanks in advance :3
In the first commit a19e3c0, I accidentally committed the doc/tags file to this repo. In commit 19870e3, I added the .gitignore file and removed doc/tags file.
After that, when I update the plugin using vim-plug. I see an error about merging. Because the remote change will overwrite the local tags file. The solution is to go to where better-escape.vim is installed and remove doc/tags file.
Then vim-plug should work without any errors.
When I open a file, go into insert mode and press jk
, the buffer is marked as changed, even though I clearly did not do any changes to the file.
It does not happen in each file, but I can't figure out what causes the problem. It happens repeatedly with init.vim
.
I'm using nvim 0.5.0. Let me know if I can give you any debug information.
Thanks for the plugin!
I tend to map jk and it's variant kj to esc. It would be nice to be able to map multiple versions to esc
For example, if we use the following mapping:
inoremap ;; <Esc>A;
We also experience lagging when we press ;
in insert mode. So we can also do the same thing. We check if the time interval between pressing the two chars is below the time threshold. If that is the case, we execute its original intended mapping, otherwise, we just insert the character literally.
Here is a crude implementation:
let g:my_map = {";;": "\<Esc>mmA;\<Esc>`ma"}
let g:char_press_time = {}
inoremap <expr> ; My_map()
augroup log_press_time
autocmd!
autocmd InsertCharPre * call Log_char()
augroup END
function! Log_char() abort
if v:char == ';'
let g:char_press_time[';'] = reltime()
endif
endfunction
function! My_map() abort
let idx = col('.')
let pre_idx = idx-1
let pre_char = getline('.')[pre_idx-1]
if pre_char == ';'
let interval = reltimefloat(reltime(g:char_press_time[";"])) * 1000
echomsg "interval:" interval
if interval < 200
return "\b" . g:my_map[";;"]
else
return ";"
endif
else
return ";"
endif
endfunction
FYI, I am checking out d3db183 to avoid the errors
Error detected while processing /Users/xxxxx/.local/share/nvim/plugged/better-escape.vim/autoload/better_escape.vim:
line 47:
E475: Invalid argument: msg, level = 'msg') abort
line 48:
E121: Undefined variable: a:level
E15: Invalid expression: a:level ==# 'err'
line 51:
E121: Undefined variable: a:msg
line 52:
E121: Undefined variable: a:level
E15: Invalid expression: a:level ==# 'err'
line 55:
E193: :endfunction not inside a function
Press ENTER or type command to continue
Hi!
I have below in my configuration
" non-ASCII shortcuts are also supported for non-English keyboard
let g:better_escape_shortcut = ['kk', 'лл']
let g:better_escape_interval = 190 "default is 150
And I use set keymap=
setting, so that I can switch insert mode layout to Russian using <C-^> shortcut.
It's also possible to change current layout using system (Windows) shortcut.
The issue is with gVim, with Russian layout activated with <C-^> (through keymap
setting above), when I type лл
it still stays in Insert mode.
This works fine with Neovim, and it works in Vim/Neovim when Russian layout is activated through system shortcut.
Thank you!
Dear,
Can we map "jk" to escape while the iBus mode is switch to another input method (here is Vietnamse Ibus-bamboo input method)
function! IBusOff()
" Lưu engine hiện tại
let g:ibus_prev_engine = system('ibus engine')
" switch to english engine
execute 'silent !ibus engine xkb:us::eng'
endfunction
function! IBusOn()
let l:current_engine = system('ibus engine')
" if engine is set in normal mode then use it
" in insert mode
if l:current_engine !~? 'xkb:us::eng'
echo "hello world"
let g:ibus_prev_engine = l:current_engine
endif
" restore the last engine
execute 'silent !' . 'ibus engine ' . g:ibus_prev_engine
endfunction
augroup IBusHandler
autocmd CmdLineEnter [/?] call IBusOn()
autocmd CmdLineLeave [/?] call IBusOff()
autocmd InsertEnter * call IBusOn()
autocmd InsertLeave * call IBusOff()
augroup END
call IBusOff()
Thanks,
Error detected while processing /home/master/dotfiles/nvim/plugged/better-escape.vim/autoload/better_escape.vim:
line 47:
E475: Invalid argument: msg, level = 'msg') abort
line 48:
E121: Undefined variable: a:level
E15: Invalid expression: a:level ==# 'err'
line 51:
E121: Undefined variable: a:msg
line 52:
E121: Undefined variable: a:level
E15: Invalid expression: a:level ==# 'err'
line 55:
E193: :endfunction not inside a function
works:
let g:better_escape_shortcut = ['jk', 'kj']
and this works too:
let g:better_escape_shortcut = ['jj', 'kk']
but if add Cyrillic letters plugin not working:
let g:better_escape_shortcut = ['jj', 'kk', 'оо', 'лл']
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.