You are not logged in.

#1 2015-11-18 06:33:00

CooKiECruNChEr43
Member
Registered: 2015-10-17
Posts: 86

[SOLVED] Vim problem: swapping the CTRL-key for the Escape-key

I want to swap the CTRL-key for the Escape-key.

How do I do it?

Offline

#2 2015-11-18 07:59:51

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,093
Website

Re: [SOLVED] Vim problem: swapping the CTRL-key for the Escape-key

Use xmodmap(1)

http://www.emacswiki.org/emacs/MovingTheCtrlKey

Once you set up ~/.xmodmap you can add this line to the end of ~/.config/openbox/autostart

xmodmap ~/.xmodmap

Offline

#3 2015-11-18 10:47:40

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,746

Re: [SOLVED] Vim problem: swapping the CTRL-key for the Escape-key

a. some reading;
http://vim.wikia.com/wiki/Avoid_the_escape_key

b. ask the freenode/#vim people.

c. ctrl+c works to break out of insert mode by default in vim, but
http://unix.stackexchange.com/questions … hing-in-vi

Last edited by brontosaurusrex (2015-11-18 10:53:28)

Offline

#4 2015-11-19 13:55:02

CooKiECruNChEr43
Member
Registered: 2015-10-17
Posts: 86

Re: [SOLVED] Vim problem: swapping the CTRL-key for the Escape-key

Head_on_Stick, the link you have given links to a page dealing with an Emacs problem. I don't want to switch the CTRL-key with the CAPS-lock key.

So that won't do. I am still searching.

Offline

#5 2015-11-19 19:13:01

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,093
Website

Re: [SOLVED] Vim problem: swapping the CTRL-key for the Escape-key

CooKiECruNChEr43 wrote:

Head_on_Stick, the link you have given links to a page dealing with an Emacs problem. I don't want to switch the CTRL-key with the CAPS-lock key.

So that won't do. I am still searching.

Read xmodmap(1)

It has an option for "Escape" so try substituting that for "Control_L" in the example in my link.

xmodmap(1) is a low-level tool that would work in vim as well as EMACS wink

Offline

#6 2015-11-23 08:52:42

CooKiECruNChEr43
Member
Registered: 2015-10-17
Posts: 86

Re: [SOLVED] Vim problem: swapping the CTRL-key for the Escape-key

Thank you for answering. Lately I have been so busy that I haven't had the chance to make it actually happen.

But you are right. The script could also work in my case. I will let you know if it worked.

Offline

#7 2015-12-20 18:02:15

CooKiECruNChEr43
Member
Registered: 2015-10-17
Posts: 86

Re: [SOLVED] Vim problem: swapping the CTRL-key for the Escape-key

I figured it out and I made a small dance of satisfaction. Here it is:
You will have to work with keycodes so run the command:

xev

This command gave me the keycodes:
Caps_Lock = keycode 66
Escape = keycode 9

You will have to switch off Caps_Lock first by using the clear-command. Then switch it on later on.
This is how the .xmodmap finally looks like:

!
!   Caps_Lock = keycode 66
!   Escape = keycode 9
!

clear Lock
keycode 66 = Escape
keycode 9  = Caps_Lock
add Lock = Caps_Lock

Add this line to the end of ~/.config/openbox/autostart

xmodmap ~/.xmodmap

Reboot your computer and done!

And again, thank you for your answers.

Last edited by CooKiECruNChEr43 (2015-12-20 18:15:10)

Offline

#8 2015-12-20 18:14:45

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,093
Website

Re: [SOLVED] Vim problem: swapping the CTRL-key for the Escape-key

CooKiECruNChEr43 wrote:

I figured it out and I made a small dance of satisfaction

egyptian.gif

Good work, thanks for posting your solution!

Offline

Board footer

Powered by FluxBB