Hello.
Is there way to map pressing <Esc> twice to something and not affecting keys giving Esc sequences? I tried nnoremap <silent><Esc><Esc> :nohl<CR> but if I press for example up arrow after first Esc, it gives strange reuslts (its frist Esc is consumed, and other chars interpreted as if there were no Esc before them). Set timeoutlen and ttimeoutelen helps, but not completely. Is ther a way to trigger map only if it is two <Esc>s and no keys after them to avoid such effects? -- Constantin Stefanov -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
On Thursday, March 22, 2012 6:34:34 PM UTC+9, Constantin Stefanov wrote:
> Hello. > > Is there way to map pressing <Esc> twice to something and not affecting > keys giving Esc sequences? > > I tried > nnoremap <silent><Esc><Esc> :nohl<CR> > > but if I press for example up arrow after first Esc, it gives strange > reuslts (its frist Esc is consumed, and other chars interpreted as if > there were no Esc before them). > > Set timeoutlen and ttimeoutelen helps, but not completely. > > Is ther a way to trigger map only if it is two <Esc>s and no keys after > them to avoid such effects? > > -- > Constantin Stefanov add space between <silent> and <esc> nnoremap <silent> <Esc><Esc> :nohl<CR> -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
Yasuhiro MATSUMOTO wrote: > On Thursday, March 22, 2012 6:34:34 PM
UTC+9, Constantin Stefanov wrote: >> Hello. >> >> Is there way to map pressing <Esc> twice to something and not affecting >> keys giving Esc sequences? >> >> I tried >> nnoremap <silent><Esc><Esc> :nohl<CR> >> >> but if I press for example up arrow after first Esc, it gives strange >> reuslts (its frist Esc is consumed, and other chars interpreted as if >> there were no Esc before them). >> >> Set timeoutlen and ttimeoutelen helps, but not completely. >> >> Is ther a way to trigger map only if it is two <Esc>s and no keys after >> them to avoid such effects? >> >> -- >> Constantin Stefanov > > add space between <silent> and <esc> > > nnoremap <silent> <Esc><Esc> :nohl<CR> -- Constantin Stefanov -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
On 03/22/12 06:42, Constantin Stefanov wrote:
> Nothing changed, Esc then up arrow gives strange results. Is this in vim or gvim? I suspect it's (non-g)vim and it's receiving an ANSI escape sequence for the arrow keys. So you'll need to tweak the 'timeoutlen' setting to be more than the time it takes you to hit <esc><esc>, but less than the time it takes you to hit <esc><arrow>. You might have better results in gvim (I don't know whether it gets actual key-codes, or they're translated into ANSI escape sequences). -tim -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
Tim Chase wrote: > On 03/22/12 06:42, Constantin Stefanov wrote: >> Nothing changed, Esc then up arrow gives strange results. > > Is this in vim or gvim? > > I suspect it's (non-g)vim and it's receiving an ANSI escape > sequence for the arrow keys. So you'll need to tweak the > 'timeoutlen' setting to be more than the time it takes you to hit > <esc><esc>, but less than the time it takes you to hit <esc><arrow>. Yes, it is vim, not gvim. I know about timeoutlen, but I hoped that there is better soultion. > You might have better results in gvim (I don't know whether it > gets actual key-codes, or they're translated into ANSI escape > sequences). I do not use gvim, so can't check. -- Constantin Stefanov -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
On 03/22/12 07:18, Constantin Stefanov wrote:
> > Tim Chase wrote: >> On 03/22/12 06:42, Constantin Stefanov wrote: >>> Nothing changed, Esc then up arrow gives strange results. >> >> Is this in vim or gvim? >> >> I suspect it's (non-g)vim and it's receiving an ANSI escape >> sequence for the arrow keys. So you'll need to tweak the >> 'timeoutlen' setting to be more than the time it takes you to hit >> <esc><esc>, but less than the time it takes you to hit<esc><arrow>. > Yes, it is vim, not gvim. I know about timeoutlen, but I hoped that > there is better soultion. the problem is that in the <esc><left> sequence, terminal Vim sees "<esc><esc>[D", so the "<esc><esc>" mapping gets triggered with the side-effect of issuing "[D" (a backwards jump and then a delete-the-rest-of-the-line). So to distinguish them, you need to tell how much time goes between the "<esc><esc>" and the "<esc><left>" which is done via 'timeoutlen'. I'd just reach for another key rather than messing with <esc><esc>. Personally, I tend to add the functionality to control+L which does a refresh anyways: :nnoremap <C-L> :noh<cr><C-L> >> You might have better results in gvim (I don't know whether it >> gets actual key-codes, or they're translated into ANSI escape >> sequences). > I do not use gvim, so can't check. if you don't have it or use it, the issue is somewhat moot there. :-) -tim -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
Tim Chase wrote: > On 03/22/12 07:18, Constantin Stefanov wrote:
>> >> Tim Chase wrote: >>> On 03/22/12 06:42, Constantin Stefanov wrote: >>>> Nothing changed, Esc then up arrow gives strange results. >>> >>> Is this in vim or gvim? >>> >>> I suspect it's (non-g)vim and it's receiving an ANSI escape >>> sequence for the arrow keys. So you'll need to tweak the >>> 'timeoutlen' setting to be more than the time it takes you to hit >>> <esc><esc>, but less than the time it takes you to hit<esc><arrow>. >> Yes, it is vim, not gvim. I know about timeoutlen, but I hoped that >> there is better soultion. > > the problem is that in the <esc><left> sequence, terminal Vim > sees "<esc><esc>[D", so the "<esc><esc>" mapping gets triggered > with the side-effect of issuing "[D" (a backwards jump and then a > delete-the-rest-of-the-line). So to distinguish them, you need > to tell how much time goes between the "<esc><esc>" and the > "<esc><left>" which is done via 'timeoutlen'. I'd just reach for > another key rather than messing with <esc><esc>. > > Personally, I tend to add the functionality to control+L which > does a refresh anyways: > > :nnoremap <C-L> :noh<cr><C-L> Esc (and more than that, single Esc) seems better. I tried to use some tricks with getchar, which can chow, is there something more in input buffer, but it seems that if I return single Esc from map, and take something alese from input, it will not be treated as Esc sequence. -- Constantin Stefanov -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
Free forum by Nabble | Edit this page |