我的emacs配置+快捷键备忘

最近开始使用emacs编辑器……

附:emacs快捷键

以下是我的emacs配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(cua-mode t nil (cua-base))
'(show-paren-mode t)
'(tool-bar-mode nil))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:family "Consolas" :foundry "outline" :slant normal :weight normal :height 130 :width normal)))))
;;自带

;;样式:
(setq default-frame-alist
'((vertical-scroll-bars)
(background-color . "black")
(foreground-color . "grey"))
)
(set-face-foreground 'region "white")
(set-face-background 'region "grey15")

;;比较有用:
(setq make-backup-files nil) ;;退出时删除生成的副本
(setq inhibit-splash-screen t) ;;关闭帮助画面
(electric-pair-mode t) ;;自动补全括号
(electric-indent-mode t) ;;花括号自动换行
(show-paren-mode t) ;;显示匹配的括号
(global-linum-mode t) ;;显示行号
(setq scroll-step 1);;每次一行一行向下翻
(setq-default cursor-type 'bar) ;;光标设为竖线
(setq default-tab-width 4) ;;默认Tab宽度
(setq c-basic-offset 4) ;;缩进宽度

;;快捷键:
(defun my-compile()
(interactive)
(save-buffer)
(let((file(file-name-nondirectory buffer-file-name)))
(compile (format "g++ -g %s -o %s" file (file-name-sans-extension file))))
(switch-to-buffer-other-window"*compilation*")
)
(global-set-key (kbd "<f9>") 'my-compile)
(global-set-key (kbd "<f5>") 'gdb)
(global-set-key (kbd "C-s") 'save-buffer)
(global-set-key (kbd "C-f") 'isearch-forward)
(global-set-key (kbd "M-<f4>") 'save-buffers-kill-emacs)
(global-set-key (kbd "C-a") 'mark-whole-buffer)