Home
home
🏡 홈
home

맥에서 emacs 키맵 사용하기

분류
개발지식
태그
Tool
UI/UX
Linux
작성자
작성일
2025/11/23 03:10
Emacs 유닉스/리눅스에서 사용하기 위해 개발된 에디터입니다. GUI환경이 아닌 텍스트 터미널에서 동작하는 것을 전제로 개발된 만큼 텍스트 에디터로는 vim 과 함께 가장 강력한 키맵을 갖고 있습니다. 이 문서는 맥에서 한글 상태에서 emacs 기본 키맵(커서 이동) 을 사용하는 법을 설명합니다.

Karabiner-Elements

먼저 다음 링크에서 Karabiner-Elements 를 다운로드 받습니다.
Karabiner-Elements 는 MacOS 에서 사용할 수 있는 강력한 무료 키맵핑 프로그램입니다.
오른쪽 Option 키를 한영 전환키로 사용하거나 특정한 프로그램에서만 동작하는 키맵핑 등을 설정할 수 있습니다.
참고로 저는 오른쪽 Option 키를 한영전환키로 사용하고 있습니다.
오른쪽 Option 키를 한영전환으로 사용하는 방법
1.
Karabiner-Elements 설정에서 Simple Modifications
2.
Add Item : right_option → F19 로 지정
3.
맥의 시스템 설정에서 > 키보드 > 입력 소스 > 이전 입력 소스 선택 을 F19 로 지정

Karabiner-Elements 설정

emacs에서 사용하는 단축키중 다음과 같은 기능을 구현하겠습니다.
Ctrl + h : 커서 앞 글자를 삭제 (Backspace) Ctrl + a : 줄의 맨 처음으로 이동 Ctrl + e : 줄의 맨 뒤로 이동 Ctrl + p : 위에 줄로 이동 Ctrl + n : 아래 줄로 이동 Ctrl + b : 커서를 왼쪽으로 이동 Ctrl + f : 커서를 오른쪽으로 이동 Ctrl + k : 커서가 있는 곳부터 줄 끝까지 오려내기 (버퍼 저장)
Makefile
복사
1.
먼저 아래 파일을 생성합니다.
mkdir -p ~/.config/karabiner/assets/complex_modifications vi ~/.config/karabiner/assets/complex_modifications/emacs_korean_ctrl.json
Bash
복사
2.
그리고 emacs_korean_ctrl.json 파일을 열어 아래 내용을 붙여넣습니다.
{ "title": "Emacs-style Ctrl keys in Korean input", "rules": [ { "description": "Emacs-style Ctrl keys", "manipulators": [ { "type": "basic", "from": { "key_code": "h", "modifiers": { "mandatory": ["control"], "optional": ["shift", "option", "command"] } }, "to": [ { "key_code": "delete_or_backspace" } ], "conditions": [ { "type": "input_source_if", "input_sources": [ { "language": "ko" } ] } ] }, { "conditions": [ { "input_sources": [{ "language": "ko" }], "type": "input_source_if" } ], "from": { "key_code": "d", "modifiers": { "mandatory": ["control"], "optional": ["shift", "option", "command"] } }, "to": [ { "key_code": "delete_forward" } ], "type": "basic" }, { "type": "basic", "from": { "key_code": "a", "modifiers": { "mandatory": ["control"], "optional": ["shift", "option", "command"] } }, "to": [ { "key_code": "left_arrow", "modifiers": ["command"] } ], "conditions": [ { "type": "input_source_if", "input_sources": [ { "language": "ko" } ] } ] }, { "type": "basic", "from": { "key_code": "e", "modifiers": { "mandatory": ["control"], "optional": ["shift", "option", "command"] } }, "to": [ { "key_code": "right_arrow", "modifiers": ["command"] } ], "conditions": [ { "type": "input_source_if", "input_sources": [ { "language": "ko" } ] } ] }, { "type": "basic", "from": { "key_code": "p", "modifiers": { "mandatory": ["control"], "optional": ["shift", "option", "command"] } }, "to": [ { "key_code": "up_arrow" } ], "conditions": [ { "type": "input_source_if", "input_sources": [ { "language": "ko" } ] } ] }, { "type": "basic", "from": { "key_code": "n", "modifiers": { "mandatory": ["control"], "optional": ["shift", "option", "command"] } }, "to": [ { "key_code": "down_arrow" } ], "conditions": [ { "type": "input_source_if", "input_sources": [ { "language": "ko" } ] } ] }, { "type": "basic", "from": { "key_code": "b", "modifiers": { "mandatory": ["control"], "optional": ["shift", "option", "command"] } }, "to": [ { "key_code": "left_arrow" } ], "conditions": [ { "type": "input_source_if", "input_sources": [ { "language": "ko" } ] } ] }, { "type": "basic", "from": { "key_code": "f", "modifiers": { "mandatory": ["control"], "optional": ["shift", "option", "command"] } }, "to": [ { "key_code": "right_arrow" } ], "conditions": [ { "type": "input_source_if", "input_sources": [ { "language": "ko" } ] } ] }, { "type": "basic", "from": { "key_code": "k", "modifiers": { "mandatory": ["control"], "optional": ["shift", "option", "command"] } }, "to": [ { "key_code": "right_arrow", "modifiers": ["command", "shift"] }, { "key_code": "delete_or_backspace" } ], "conditions": [ { "type": "input_source_if", "input_sources": [ { "language": "ko" } ] } ] } ] } ] }
JSON
복사
3.
마지막으로 Karabiner 의 Complex Modifications 메뉴에서 Add Predefined rule 에서 설정을 불러오면 됩니다.

팁 1

위 코드를 보시면 한글 상태에서만 위 단축어가 동작하도록 되어있습니다. 그 이유는 기본적으로 맥에서는 영어모드(cocoa mode)에서는 emacs 단축키를 대부분 잘 지원하기 때문입니다. 그만큼 emacs 키맵은 표준 키맵이라고 불 수 있습니다.
위 단축키는 아주 기본적인 것들만 설명한 것이고 emacs 키맵은 정말 방대하고 막강합니다. 관심있는 분들은 아래 링크를 확인하세요.

팁 2

단축어가 모두 Ctrl + 문자로 되어있습니다.
우리가 일반적으로 보는 IBM-PC 101키 키보드는 Ctrl 키가 왼쪽에 있습니다. 이 위치는 새끼손가락을 꺽어서 입력해야하는데 단축키를 Ctrl 의 조합으로 만드는 게 불편해보일 수 있습니다.
이럴 때는 잘 사용하지 않은 Caps Lock 키를 Ctrl 키로 변환해서 사용하면 왼손 새끼손가락이 자연스럽게 내려오는 위치를 사용할 수 있어 피로도가 상당히 적어집니다. 백스페이스를 누르기 위해 오른손을 오른쪽 위로 꺽지 않아도 되고, 방향키를 누르기 위해 팜레스트에서 손목을 이동할 필요도 없습니다.
이 위치(Caps Lock 위치)에 Ctrl 키가 있는 키보드 배열을 Ansi-PC Layout 이라고 하고, Programmer World 라고도 합니다. 그만큼 개발자에게 특화되어있는 배열이라는 뜻이죠.
이글을 보는 분은 대부분 개발자일겁니다. Programmer World 로 오세요~!