Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am a long time Mac user and I'm now using a Ubuntu machine for development, and while I'm more or less used to a lot of the keyboard shortcuts, one thing I can't get used to is using the 'Home' and 'End' keys to move around lines of text. On a Mac you use "Command + right arrow" to go to the end of a line and "Command + left arrow" to go to the beginning.

Is there a way to enable this kind of functionality in Linux?

I'm not sure if this would be considered remapping, keyboard shortcuts, or what...

share|improve this question

3 Answers 3

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.

share|improve this answer

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:

  1. Let the left Alt key be the so called Mode_switch:

    1. Assign the key the Mode_switch key sym:

      xmodmap -e 'keycode  64 = Mode_switch Meta_L Alt_L Meta_L'
      
    2. (Normally: Make sure that Mode_switch is assigned to one of the mod1-5 modifier keys, but this is already the case in Ubuntu)

  2. Modify the third row of the Left and Right keys

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

share|improve this answer

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

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.