Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

OS X by default supports emacs key bindings, for example Ctrl+A to go to the beginning of the line, My problem is when I switch to a different language these Ctrl key bindings stop working.

Is it possible to either modify the keyboard layout to send English letters when the key is pressed with Ctrl. Or add new binding to OS X that accept the Ctrl binding with the correspoding letters in the other input source. Or is there a third choice?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

I tried modifying some non-Latin layouts that came with Ukelele, but couldn't get shortcuts like control+A to work with them. I haven't found a way to get them to work with my custom keyboard layout either, but I'm probably just missing something...

Another option would be to create ~/Library/KeyBindings/ save a property list like this as DefaultKeyBinding.dict:

{
    "^ф" = moveToBeginningOfParagraph:; // ctrl-a on the Russian layout
    "^щ" = (insertNewlineIgnoringFieldEditor:, moveBackward:); // ctrl-o on the Russian layout
    // ...
}

Some of the default control key actions, copied from lri.me/keybindings:

"^p" = moveUp:;
"^n" = moveDown:;
"^b" = moveBackward:;
"^f" = moveForward:;
"^h" = deleteBackward:;
"^d" = deleteForward:;
"^a" = moveToBeginningOfParagraph:;
"^e" = moveToEndOfParagraph:;
"^k" = deleteToEndOfParagraph:;
"^l" = centerSelectionInVisibleArea:;
"^v" = pageDown:;
"^t" = transpose:;
"^y" = yank:;
"^o" = (insertNewlineIgnoringFieldEditor:, moveBackward:);
"^P" = moveUpAndModifySelection:;
"^N" = moveDownAndModifySelection:;
"^B" = moveBackwardAndModifySelection:;
"^F" = moveForwardAndModifySelection:;
"^A" = moveToBeginningOfParagraphAndModifySelection:;
"^E" = moveToEndOfParagraphAndModifySelection:;
"^V" = pageDownAndModifySelection:;
"~^b" = moveWordBackward:;
"~^f" = moveWordForward:;
"~^B" = moveWordBackwardAndModifySelection:;
"~^F" = moveWordForwardAndModifySelection:;
share|improve this answer
    
Thanks Lri, I guess that is the only option. –  Ammar Abdulaziz Mar 24 '12 at 0:57
    
Sadly it doesn't work, it gives the error sound as if the key combination is invalid, I even made the keybinding with hex characters and it didn't work. Does it work for you? –  Ammar Abdulaziz Mar 26 '12 at 3:41
    
@AmmarAbdulaziz I did get the examples to work with the Russian layout. Have you tried validating the property list with plutil ~/Library/KeyBindings/DefaultKeyBinding.dict? –  Lauri Ranta Mar 26 '12 at 12:05
    
Says it's valid.Maybe it'a an issue with Arabic? Because that's the language I'm trying to use. –  Ammar Abdulaziz Mar 26 '12 at 15:40
    
They work! Thanks a lot. –  Ammar Abdulaziz Mar 31 '12 at 18:09
add comment

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.