Mapping CTRL-BACKSPACE to CTRL-W

504 views
Skip to first unread message

Sadarax

unread,
Feb 13, 2008, 2:20:20 PM2/13/08
to Vim
I am trying to make CTRL-BACKSPACE to CTRL-W in my vimrc. But it does not seem tow rok. Here is what I have:

:inoremap <C-BS> <C-W>

Can anyone help with this? (And does anyone know how to map this in the BASH shell too?)

-Sadarax

--
How sad it would be to live a life less wonderful, if only because one were afraid of a little hard work. If you shy away from challenges, you shy away from some of the greatest achievements in life.

Richard Hartmann

unread,
Feb 13, 2008, 3:56:53 PM2/13/08
to vim...@googlegroups.com
On Feb 13, 2008 8:20 PM, Sadarax <sad...@gmail.com> wrote:


> Can anyone help with this? (And does anyone know how to map this in the BASH
> shell too?)

Try #bash on freenode.


Richard

Gary Johnson

unread,
Feb 13, 2008, 4:54:21 PM2/13/08
to vim...@googlegroups.com
On 2008-02-13, Sadarax <sad...@gmail.com> wrote:
> I am trying to make CTRL-BACKSPACE to CTRL-W in my vimrc. But it does not seem
> tow rok. Here is what I have:
>
> :inoremap <C-BS> <C-W>
>
> Can anyone help with this? (And does anyone know how to map this in the BASH
> shell too?)

Are you trying to do this in gvim or in vim? It works fine for me
in gvim. It won't work in vim, however. There is no ASCII
character for <C-BS> and there is no termcap/terminfo code for
<C-BS>. Hence, terminals have no standard way to encode the <C-BS>
key combination to send to vim.

Regards,
Gary

Eric Tetz

unread,
Feb 13, 2008, 5:20:46 PM2/13/08
to vim...@googlegroups.com
On Feb 13, 2008 1:54 PM, Gary Johnson <gary...@spk.agilent.com> wrote:
> Are you trying to do this in gvim or in vim?  It works fine for me
> in gvim.  It won't work in vim, however.

Working for me in Gvim, too (7.1).

Doesn't work in Vim if I use :inoremap <C-BS> <C-W>, but I can use <C-V> to enter control-backspace, which gives me the character 0x7F (which on my terminal gives me a symbol looking like a pyramid).

Tony Mechelynck

unread,
Feb 13, 2008, 5:33:08 PM2/13/08
to vim...@googlegroups.com
Eric Tetz wrote:
> On Feb 13, 2008 1:54 PM, Gary Johnson <gary...@spk.agilent.com

0x7F is supposed to be Control-question mark, known to Vim as <C-?>


Best regards,
Tony.
--
Microsoft's definition of a boolean: TRUE, FALSE, MAYBE
"Embrace and extend"...?

Sadarax

unread,
Feb 13, 2008, 6:43:36 PM2/13/08
to vim...@googlegroups.com
Thanks for the information.

Well, maybe this is not the greatest solution, but this is what I have created so far:

:inoremap <C-?> <C-W>

This sets the backspace key (interpreted as '<C-?>') to function for delete-word more or less. Now, of course I do not have a normal backspace function, but I counter this by using <C-h> for standard backspace.

Gary Johnson

unread,
Feb 13, 2008, 8:39:58 PM2/13/08
to vim...@googlegroups.com
On 2008-02-13, Sadarax <sad...@gmail.com> wrote:
> Thanks for the information.
>
> Well, maybe this is not the greatest solution, but this is what I have created
> so far:
>
> :inoremap <C-?> <C-W>
>
> This sets the backspace key (interpreted as '<C-?>') to function for
> delete-word more or less. Now, of course I do not have a normal backspace
> function, but I counter this by using <C-h> for standard backspace.

It's not clear to me why you don't have normal backspace behavior
from your Backspace key. I started playing with this a bit and
discovered that the Backspace key on my keyboard emits <BS> (^H) but
that Ctrl-Backspace emits <Del> (^?). That's when running vim in an
xterm window under KDE on a Red Hat Linux system. So

:inoremap <C-?> <C-W>

gives me exactly the behavior you want.

It could be that your system is configured so that your Backspace
key normally emits <Del> and so that Ctrl-Backspace is
indistinguishable from Backspace. You might be able to fix that, at
least while running vim. This is discussed a bit in ":help fixdel".

Regards,
Gary

Sadarax

unread,
Feb 13, 2008, 8:54:18 PM2/13/08
to vim...@googlegroups.com
I am running Vim in Screen (all the time) under KDE 3.x in Ubuntu 7.10. I will be looking into this. Thanks. If anyone figures it out, please post.

-Sadarax

Reply all
Reply to author
Forward
0 new messages