Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'd like to change the default behaviour when editing text.

By default, to move one word along, one would press CTRL+. This is useful for selecting portions of text quickly when in normal* text environments.

Where can I modify this to use a different modifier key (e.g. ALT)? I can't find it in the Keyboard Layout > Options or in the Keyboard > Shorcuts.

*i.e. not Vim/other editor

share|improve this question

2 Answers 2

  1. You can use xbindkeys to override certain keys on your keyboard. You can catch them with bindkeys, and then emit new keypresses using xmacro

see the following howto

  1. It could be also a Compiz Setting. check if you have installed Compiz

  2. Enter the following in your command-line, this should do the job

bindkey '^[[5D' emacs-backward-word
bindkey '^[[5C' emacs-forward-word

share|improve this answer

That depends on which program you mean. Unfortunately, this is not a global shortcut, but every application decides on its own how to implement that. This is why it is not present in the global system shortcuts.

What you can do is to catch the "Alt-Right" combination -- and xbindkeys here, as mentioned in another reply, a way to solve that -- and let it emit "Ctrl-Right". This will achieve using Alt-Right for jumping to the next word. But there is a downside: you will not be able to get rid of the "Ctrl-Right" combination doing the same.

OK, so how exactly does the configuration with xbindkeys looks like. It is much less straightforward than it looks like at first. I tried to do it below, but it turned out to be next to impossible.

First, install xmacro and xbindkeys, and create the rc file for xbindkeys.

sudo apt-get install xmacro xbindkeys xbindkeys-config
xkbindkeys -d > $HOME/.xbindkeysrc

Next, enter the following two lines into the .xbindkeysrc file:

"{ echo KeyStrRelease Alt_L ; echo KeyStrRelease Alt_R ; echo KeyStrRelease  Right ; echo KeyStrPress Control_L ; echo KeyStrPress Right ; echo KeyStrRelease Right; echo KeyStrRelease Control_L ; } | xmacroplay -d 0 :0.0  } | xmacroplay -d 0 :0.0"
   Alt + Right
"{ echo KeyStrRelease Alt_L ; echo KeyStrRelease Alt_R ; echo KeyStrRelease Left ; echo KeyStrPress Control_L ; echo KeyStrPress Left ; echo KeyStrRelease Left ; echo KeyStrRelease Control_L ; } | xmacroplay -d 0 :0.0  } | xmacroplay -d 0 :0.0"
   Alt + Left

What this will do: when you first press Alt-Right, xbindkeys will run the command; but beware! the keys alt and right are still pressed. We must "unpress" them first. The above works, but not perfectly, be warned. Most importantly, to jump two words, you have the press the combination, release it, and press again; with ctrl-right, you can press the combination, and then repeat the press on the right arrow as many times as needed.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.