remap C-\ to a different C- key ?

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

remap C-\ to a different C- key ?

M Kelly
Hi,

Is it possible to remap C-\ to a different C- key ?

thx for all that is vim,
-m

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

Re: remap C-\ to a different C- key ?

Tony Mechelynck
On Mon, Dec 17, 2018 at 1:31 PM M Kelly <[hidden email]> wrote:
>
> Hi,
>
> Is it possible to remap C-\ to a different C- key ?

1. Do you mean "make it do something else than its default action" or
"make a different key act like Ctrl-\"?
2. Have you tried?

If you have, and been unsuccessful, what exactly did you do (step by
step), and on which Vim version on which OS?

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
|

Re: remap C-\ to a different C- key ?

M Kelly
Tony, hi

Sorry for not being more precise -
I mean make another key do what C-\ does, but my difficult point is
that another program (like a window mgr etc.) might grab C-\ before vim,
so I don't mean map C-x to C-\ for exmaple.

thx,
-m

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

Re: remap C-\ to a different C- key ?

Tony Mechelynck
On Mon, Dec 17, 2018 at 1:58 PM M Kelly <[hidden email]> wrote:

>
> Tony, hi
>
> Sorry for not being more precise -
> I mean make another key do what C-\ does, but my difficult point is
> that another program (like a window mgr etc.) might grab C-\ before vim,
> so I don't mean map C-x to C-\ for exmaple.
>
> thx,
> -m

Apparently you didn't try.

The best keys to use as {lhs} in Vim are the Fn keys, with or without
Shift (your window manager might grab those with Ctrl) with the
exception of unshifted F1 (Help) and possibly F10 (Menu), plus any
non-ASCII printing key your keyboard might have (for instance mine has
² ³ § é è ç à ù µ £ plus a dead key for diaeresis and circumflex, and
that's before adding all my AltGr combinations).

So I tried
        :cmap <S-F12> <C-\>
(in my usual gvim, a Big build of Vim 8.1.606 with GTK2 GUI) and it
worked (i.e. Shift-F12 e on the command line did what Ctrl-\ e is
supposed to do). (The operands are of course typed in full, in <>
notation.)

To remap it in all modes, use both
        :map <S-F12> <C-\>
        :map! <S-F12> <C-\>
possibly replacing <S-F12> by the <> representation of any other Fn
key you aren't yet using as the {lhs} of a mapping.


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
|

Re: remap C-\ to a different C- key ?

M Kelly
Hi,

If the window mgr grabs C-\ then I don't think it will work ?
I did test but will test again, I propably messed something up.

I think what I'm hoping for is if perhaps we knew something like:
C-\ calls function foo() ...
then I can unmap C-\ and map C-x (or S-F12) to call function foo()
and then I get the same functionality from a different key sequence
and the window mgr can grab C-\ all it wants.

thx so much for your help,
-m

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

Re: remap C-\ to a different C- key ?

Christian Brabandt

On Mo, 17 Dez 2018, M Kelly wrote:

> Hi,
>
> If the window mgr grabs C-\ then I don't think it will work ?
> I did test but will test again, I propably messed something up.
>
> I think what I'm hoping for is if perhaps we knew something like:
> C-\ calls function foo() ...
> then I can unmap C-\ and map C-x (or S-F12) to call function foo()
> and then I get the same functionality from a different key sequence
> and the window mgr can grab C-\ all it wants.

I am not sure what exact command you want to map, since there are a
couple of C-\ commands within Vim available. But even if your window
manager grabs C-\ you can still map another key to send the C-\ as the
window manager won't receive the key from inside Vim. So

nnoremap <f6> <c-\>

will make the <f6> key an alias to the <c-\>

Best,
Christian
--
Und hier noch eine wichtige Verkehrsdurchsage: Der Idiot, der auf der
Autobahn A9 in falscher Richtung fuhr, klebt jetzt am Kühler eines
Lasters und fährt wieder in richtiger Richtung.

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

Re: remap C-\ to a different C- key ?

M Kelly
Hi,

> window manager won't receive the key from inside Vim. So

I think this is the issue - for me yes, the window mgr wins
and I try to make sure it and vim do not use the same key sequences.

thx,
-m

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

Re: remap C-\ to a different C- key ?

Tony Mechelynck
In reply to this post by M Kelly
On Mon, Dec 17, 2018 at 3:56 PM M Kelly <[hidden email]> wrote:
>
> Hi,
>
> If the window mgr grabs C-\ then I don't think it will work ?
> I did test but will test again, I propably messed something up.

As Christan said, if you map something else to Ctrl-\ the Ctrl-\ will
never be actually generated and your window manager won't see it. For
instance, if you add to your vimrc
      noremap <F6> <C-\>
      noremap! <F6> <C-\>
then save it and restart Vim, when you hit F6 your window manager will
see F6, pass it to Vim, which will interpret it as having the function
of Ctrl-\.

It is not needed to unmap Ctrl-\, you can have several keys for a
single function. If you do
        :map <C-\> <Nop>
then Vim won't act on the Ctrl-\ key combo even if the winmanager
doesn't grab it but it will still act on the :noremap'ped F6.

>
> I think what I'm hoping for is if perhaps we knew something like:
> C-\ calls function foo() ...

By default, Ctrl-\ calls different functions in C depending on
context, we have no access to those; but if we map something to <C-\>
it will call those same C functions in the same contexts, and the
winmanager will never see a Ctrl-\

> then I can unmap C-\ and map C-x (or S-F12) to call function foo()
> and then I get the same functionality from a different key sequence
> and the window mgr can grab C-\ all it wants.
>
> thx so much for your help,
> -m

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
|

Re: remap C-\ to a different C- key ?

M Kelly
In reply to this post by M Kelly
Hi,

I made progress after finding my mistakes.
I will map 'something else' to C-\ in terminal mode and command mode.
Thank you again for your replies which help so much.

take care,
-m

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

Re: remap C-\ to a different C- key ?

arocker

Does anyone else feel nostalgia for the days when, once you'd got the
terminal running at the right frequency, length and parity, you didn't
have to worry about an unknown number of functions leaping out from under
their bridges to molest your character strings, (except for Ctl-s)? :-)*

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