emacs 편집기 활용 팁

emacs를 써보고 싶은 생각에 emacs-snapshot을 설치하고 손에 익혀 가면서 공부하고 있습니다. vim만 사용하다가 갑자기 emacs를 쓰다보니 단축키가 헷갈리지만 emacs도 vim만큼 소스코드를 작성하는 재미가 있습니다.

emacs를 처음 시작하면서 참조했던 사이트나 수정해야 했던 몇가지 팁을 정리했습니다.

1. 한글설정 하기

emacs 23 개발버전인 emacs-snapshot을 설치하고 다음과 같이 설정파일에 입력하면 사용하고 싶은 한글 글꼴을 설정할 수 있습니다.

;; 원하는 글꼴로 변경합니다.
(set-fontset-font "fontset-default" '(#x1100 . #xffdc)  '("Malgun Gothic" . "unicode-bmp"))
(set-fontset-font "fontset-default" '(#xe0bc . #xf66e)  '("New Gulim" . "unicode-bmp"))
(set-fontset-font "fontset-default" 'kana '("Meiryo" . "unicode-bmp"))
(set-fontset-font "fontset-default" 'han '("Microsoft YaHei" . "unicode-bmp"))

참조 사이트: http://kldp.org/node/76157/360514#comment-360514

2. vim에 있는 set nu 명령 그대로 이용하기

vim에 있는 set nu 명령 역시 emacs에도 있습니다. emacs 설정 파일에 다음과 같이 입력하면 소스코드 옆에 라인번호가 나옵니다.

(add-hook 'find-file-hook (lambda ()(linum-mode 1)))
;; 하단에 커서가 위치한 라인 넘버 표시
(line-number-mode 1)
;; 하단에 커서가 위치한 컬럼 넘버 표시
(column-number-mode 1)

참조 사이트: http://www.emacswiki.org/emacs/LineNumbers

3. 커서 라인 하이라이팅 하기

아래와 같이 입력하면 커서가 위치한 라인이 하이라이팅됩니다. 전경색, 배경색만 사용하고 싶은 색깔로 설정하면 됩니다.

(global-hl-line-mode 1)
(set-face-background 'hl-line "#222")
(set-face-foreground 'highlight nil)
(set-face-foreground 'hl-line nil)

참조 사이트: http://www.emacsblog.org/2007/04/09/highlight-the-current-line

4. 한줄씩 삭제하기

vim의 dd 명령과 비슷한 효과를 나타냅니다.

(defun nuke-line()
  "Kill an entire line, including the trailing newline character"
  (interactive)
  (setq previous-column (current-column))
  (end-of-line)
 
  (if (= (current-column) 0)
    (delete-char 1)
    (progn
      (beginning-of-line)
      (kill-line)
      (delete-char 1)
      (move-to-column previous-column))))
 
;; 원하는 단축키로 설정합니다.
(global-set-key [f8] 'nuke-line)

참조 사이트: http://homepages.inf.ed.ac.uk/s0243221/emacs

5. 도움이 되는 사이트

이 문서에서 emacs 단축키를 나열하는 것보다 잘 정리된 사이트를 참조하는 것이 더 도움이 될 것 같아서 링크를 남깁니다.

이멕스, vim 의 설정파일을 공유하는 사이트: http://www.dotfiles.com
KLDP wiki의 emacs 튜토리얼 사이트: http://wiki.kldp.org/wiki.php/EmacsGdbEtagsCscope
Emacs 메뉴얼 사이트: http://www.gnu.org/software/emacs/manual/html_node/emacs/index.html#Top

Creative Commons License
This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 2.0 Korea License.
This entry was posted in Development and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">