Enable Ctrl (or Alt) + arrow keys to mimic 'home' and 'end' functionality
Solution 1:
Using xmodmap
(some hints) you can rebind keys for the whole window system. The following approach will deliver what you want, but with side effects :(
Try it out in a terminal window first:
-
Let the left
Alt
key be the so calledMode_switch
:-
Assign the key the Mode_switch key sym:
xmodmap -e 'keycode 64 = Mode_switch Meta_L Alt_L Meta_L'
(Normally: Make sure that Mode_switch is assigned to one of the mod1-5 modifier keys, but this is already the case in Ubuntu)
-
-
Modify the third row of the
Left
andRight
keysxmodmap -e 'keycode 113 = Left NoSymbol Home' xmodmap -e 'keycode 114 = Right NoSymbol End'
As is the changes are kept until you log out. If you wish to keep it permanently put the following into a file ~/.Xmodmap
:
keycode 64 = Mode_switch Meta_L Alt_L Meta_L
keycode 113 = Left NoSymbol Home
keycode 114 = Right NoSymbol End
However be warned that this overrides the normal function of your Alt key (accessing menu, Alt-Tab etc.) :(
I am not an expert in xmodmap & Co, though. Maybe someone else knows how to fix this. I really like Ubuntu and Linux in general, but this whole keyboard stuff is unnecessarily complicated and sorrowly broken :-<
Solution 2:
This is specifically for sublime text, but for anyone searching for a way to remap alt and the arrow keys to behave like on a mac might stumble across this answer like I have. In sublime, open Preferences > Key Bindings - User and add the following between the square brackets.
{ "keys": ["alt+left"], "command": "move_to", "args": {"to": "bol", "extend": false} },
{ "keys": ["alt+right"], "command": "move_to", "args": {"to": "eol", "extend": false} }
now, at least you have a useful text editor with proper behaving alt + left and right arrows! Hope this helped a little bit.
Solution 3:
For programs that use readline (e.g. bash) you can edit ~/.inputrc
to bind beginning-of-line
and end-of-line
to the appropriate sequence. GUI widget toolkits have their own bindings, and you'll have to find the appropriate bits and pieces for them, assuming it's possible at all (GTK+ 2.x).