Wednesday, March 4, 2015

Re: How to cancel [count] prefix?

On 4 mars 2015, at 20:37, Nikolay Pavlov <zyx.vim@gmail.com> wrote:

>> For Normal and Visual modes, i plan however to remap my `<Esc>` key using something like this:
>>
>> function s:NVMapExpr_EscKey()
>> if v:count
>> return '@_'
>> else
>> return "\<Esc>"
>> endif
>> endfunction
>> nnoremap <expr> <Esc> <SID>NVMapExpr_EscKey()
>> vnoremap <expr> <Esc> <SID>NVMapExpr_EscKey()
>
> I would suggest to simply do
>
> noremap <expr> <Esc> (v:count?'@_':"\e")
> onoremap <expr> <Esc> (v:count?repeat("\<LT>DEL>",len(v:count)):"\e")
>
> . Function is an overkill here.

Thanks, nice.

A.

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment