Saturday, January 25, 2014

การทำปุ่ม Home, End บน Mac. OS ให้เหมือน Windows OS

ปัญหาหนึ่งที่พบเจอบ่อยๆ คือความคุ้นเคยในการใช้ text editor บน windows แล้วพอสลับไปใช้เครื่อง mac. คือการหลงไปกดปุ่ม Home หรือ End แทนที่จะไปที่หัวหรือท้ายบรรทัด แต่กลับกระโดดไปที่ส่วนบนสุดหรือล่างสุดของไฟล์ทำให้เสียเวลามาก วิธีแก้คือเข้าไปเพิ่มไฟล์ DefaultKeyBinding.dict เข้าไปในระบบ

To get your Home and End keys working properly on Mac OS X (in my case, Mountain Lion, although this should work in prior versions back to at least Tiger), simply open the Terminal and do this:

$ cd ~/Library
$ mkdir KeyBindings
$ cd KeyBindings
$ nano DefaultKeyBinding.dict

Put these lines in that file, including the curly braces:

{
/* Remap Home / End keys to be correct */
"\UF729" = "moveToBeginningOfLine:"; /* Home */
"\UF72B" = "moveToEndOfLine:"; /* End */
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */
"$\UF72B" = "moveToEndOfLineAndModifySelection:"; /* Shift + End */
"^\UF729" = "moveToBeginningOfDocument:"; /* Ctrl + Home */
"^\UF72B" = "moveToEndOfDocument:"; /* Ctrl + End */
"$^\UF729" = "moveToBeginningOfDocumentAndModifySelection:"; /* Shift + Ctrl + Home */
"$^\UF72B" = "moveToEndOfDocumentAndModifySelection:"; /* Shift + Ctrl + End */
}

Press Ctrl+O and then Enter to save the file, and Ctrl+X to exit. Restart your computer to have it take full effect.

แต่ในบางโปรแกรมที่มีความฉลาดในการกำหนดคีย์เองอยู่แล้วก็สามารถเข้าไปกำหนดได้เลย เช่น Eclipse โดยเข้าไปที่ Preferences -> General.Keys -> Text Editing

source:
http://mwholt.blogspot.com/2012/09/fix-home-and-end-keys-on-mac-os-x.html
http://www.kelek.com/blog/2006/09/16/fixing_home_end.html

No comments:

Post a Comment