execute "set <key>=..."

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

execute "set <key>=..."

Lifepillar
Using Vim on macOS, I had this in my .vimrc:

     cmap <esc>b <s-left>
     cmap <esc>f <s-right>

which allowed me to use <alt>-arrows in command mode to jump
between words. It worked, but it caused a 'timeout' delay
when I was pressing <esc> to exit command mode.

I have recently discovered that I can do this instead:

     execute "set <s-left>=\eb"
     execute "set <s-right>=\ef"
     execute "cmap \eb <s-left>"
     execute "cmap \ef <s-right>"

This works exactly the same, and <esc> does not cause any delay
(I have ttimeoutlen=10 if that matters). Great!

So, here are my questions:

1) What do the commands above do exactly?
2) Where is ":set <some-key>=" explained in the manual?
3) Is it possible to rewrite the commands without :execute?
4) Is there any drawback or side effect I should be aware of?

Thanks,
Life.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: execute "set <key>=..."

Tony Mechelynck
On Thu, Jul 13, 2017 at 6:06 PM, Lifepillar <[hidden email]> wrote:

> Using Vim on macOS, I had this in my .vimrc:
>
>     cmap <esc>b <s-left>
>     cmap <esc>f <s-right>
>
> which allowed me to use <alt>-arrows in command mode to jump
> between words. It worked, but it caused a 'timeout' delay
> when I was pressing <esc> to exit command mode.
>
> I have recently discovered that I can do this instead:
>
>     execute "set <s-left>=\eb"
>     execute "set <s-right>=\ef"
>     execute "cmap \eb <s-left>"
>     execute "cmap \ef <s-right>"
>
> This works exactly the same, and <esc> does not cause any delay
> (I have ttimeoutlen=10 if that matters). Great!
>
> So, here are my questions:
>
> 1) What do the commands above do exactly?
> 2) Where is ":set <some-key>=" explained in the manual?
> 3) Is it possible to rewrite the commands without :execute?
> 4) Is there any drawback or side effect I should be aware of?
>
> Thanks,
> Life.

1) :set <code>=xyz tells Vim which bytes the terminal sends (or, in
some cases, expects) for that code. It can also be used for termcap
codes, and if neither of the two characters of the termcap item name
are special characters, you can dispense with the <> around it: e.g.
:set t_Co=256 to tell Vim that your present console supports 256
colours rather than the minimum 8 background and 16 foreground.
2) :help :set-termcap
3) yes
4) if your terminal sends some other set of bytes for Shift-Left
and/or Shift-Right, Vim will stop recognizing those keys when you hit
them.

Best regards,
Tony.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: execute "set <key>=..."

Lifepillar
On 13/07/2017 18:50, Tony Mechelynck wrote:

> On Thu, Jul 13, 2017 at 6:06 PM, Lifepillar <[hidden email]> wrote:
>> Using Vim on macOS, I had this in my .vimrc:
>>
>>      cmap <esc>b <s-left>
>>      cmap <esc>f <s-right>
>>
>> which allowed me to use <alt>-arrows in command mode to jump
>> between words. It worked, but it caused a 'timeout' delay
>> when I was pressing <esc> to exit command mode.
>>
>> I have recently discovered that I can do this instead:
>>
>>      execute "set <s-left>=\eb"
>>      execute "set <s-right>=\ef"
>>      execute "cmap \eb <s-left>"
>>      execute "cmap \ef <s-right>"
>>
>> This works exactly the same, and <esc> does not cause any delay
>> (I have ttimeoutlen=10 if that matters). Great!
>>
>> So, here are my questions:
>>
>> 1) What do the commands above do exactly?
>> 2) Where is ":set <some-key>=" explained in the manual?
>> 3) Is it possible to rewrite the commands without :execute?
>> 4) Is there any drawback or side effect I should be aware of?
>>
>> Thanks,
>> Life.
>
> 1) :set <code>=xyz tells Vim which bytes the terminal sends (or, in
> some cases, expects) for that code. It can also be used for termcap
> codes, and if neither of the two characters of the termcap item name
> are special characters, you can dispense with the <> around it: e.g.
> :set t_Co=256 to tell Vim that your present console supports 256
> colours rather than the minimum 8 background and 16 foreground.

Crystal clear!

> 2) :help :set-termcap
> 3) yes
Ok, your answer to 2) also helped me solve 3). I have two more questions
though. First, with entries like t_BE I may write:

     let &t_BE = "\033[?2004h"

which allows me to avoid typing a literal escape key. Is this syntax
somehow usable with the <...> form?

Second, how is

     cmap <esc>b <s-left>

different from

     cmap ^[b <s-left>

(where ^[ is a literal esc)? If I use the latter, Vim does not use
'timeout' when I type esc. But why? Isn't that esc followed by b anyway?

> 4) if your terminal sends some other set of bytes for Shift-Left
> and/or Shift-Right, Vim will stop recognizing those keys when you hit
> them.

That makes sense.

Thanks,
Life.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: execute "set <key>=..."

Lifepillar
On 13/07/2017 20:55, Lifepillar wrote:

> Second, how is
>
>      cmap <esc>b <s-left>
>
> different from
>
>      cmap ^[b <s-left>
>
> (where ^[ is a literal esc)?

Never mind, I have found this article, which explains it very well:

http://vim.wikia.com/wiki/Mapping_fast_keycodes_in_terminal_Vim

Life.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...