.emacsの便利な設定
.emacsのいろいろな設定を載せておきます。
必要に応じてコピーして使ってください。
;;;------------------------------------------------;;;
;;;-----------------Emacs本体の設定----------------;;;
;;;------------------------------------------------;;;
;; font-lockを有効にする
(global-font-lock-mode t)
;; バッファの最後で勝手に新しい行を追加しないようにする
(setq next-line-add-newlines nil)
;; ミニバッファに時計を表示
(display-time)
;; モードラインに行番号と列番号を表示
(line-number-mode t)
(column-number-mode t)
;; リージョンを強調表示
(transient-mark-mode t)
;; 対応する括弧を強調表示
(show-paren-mode t)
;; マウスの右クリックの割り当て(押しながらの操作)をはずす
(if window-system (progn
(global-unset-key [down-mouse-3])
;; マウスの右クリックメニューを使えるようにする
(defun bingalls-edit-menu (event) (interactive "e")
(popup-menu menu-bar-edit-menu))
(global-set-key [mouse-3] 'bingalls-edit-menu)))
;; 日本語があってもスペルチェックできるようにする
(eval-after-load "ispell"
'(setq ispell-skip-region-alist (cons '("[^\000-\377]")
ispell-skip-region-alist)))
;; shell-modeで矢印キーの上下でコマンド履歴を表示
(setq shell-mode-hook
(function (lambda ()
(define-key shell-mode-map [up] 'comint-previous-input)
(define-key shell-mode-map [down] 'comint-next-input))))
;;;------------------------------------------------;;;
;;;------------キー割り当てに関する設定------------;;;
;;;------------------------------------------------;;;
;; goto-line を M-g に割り当て
(global-set-key "\M-g" (lambda (x) (interactive "nLine: ") (goto-line x)))
;; C-x ; でコメントアウト
;; C-x : でコメントをはずす
(global-set-key "\C-x;" 'comment-region)
(fset 'uncomment-region "\C-u\C-[xcomment-region\C-m")
(global-set-key "\C-x:" 'uncomment-region)
;; C-h をBackspaceに割り当て
(global-set-key "\C-h" 'delete-backward-char)
;; C-o を日本語入力の切り替えに割り当て
(global-set-key "\C-o" 'toggle-input-method)
;; 分割したウィンドウ間を Shift + 矢印キー で移動
(windmove-default-keybindings)
(setq windmove-wrap-around t)
;; C-x p で C-x o の逆の操作(前のウィンドウへ移動)
(global-set-key "\C-xp" (lambda () (interactive) (other-window -1)))
その他の項目へのリンク
- Emacsの使いかた
- コマンド一覧表
- .emacsの便利な設定
- ちょっとした小技集
- リンク集