考场配置:
C++;;在配置后面会对语句逐一解释的
(global-set-key (kbd "C-z") 'undo)
(global-set-key (kbd "C-a") 'mark-whole-buffer)
(global-set-key [f9] 'compile-file)
(global-set-key [f10] 'eshell)
(defun compile-file ()
(interactive)
(compile (format "g++ -o %s %s -g -lm -Wall" (file-name-sans-extension (buffer-name))(buffer-name))))
(cua-mode t)
(show-paren-mode t)
(global-linum-mode t)
(global-hl-line-mode 1)
(setq kill-ring-max 200)
(setq default-cursor-type 'bar)
(setq default-tab-width 4)
(setq c-default-style "awk")
(set-frame-parameter (selected-frame) 'alpha (list 85 50))
(setq default-frame-alist'(
(background-color . "black")
(foreground-color . "grey")
(cursor-color . "gold1")
)
)
语句解释:
C++(global-set-key (kbd "C-z") 'undo)
(global-set-key (kbd "C-a") 'mark-whole-buffer)
(global-set-key [f9] 'compile-file)
(global-set-key [f10] 'eshell)
(defun compile-file ()
(interactive)
(compile (format "g++ -o %s %s -g -lm -Wall" (file-name-sans-extension (buffer-name))(buffer-name))))
;;快捷键第一行是撤销,第二行全选,第三行编译,第四行调试后面一段是一件编译设定(按F9执行)。
(cua-mode t)
;;Windows的复制粘贴键在菜单的options里有!
(show-paren-mode t)
(global-linum-mode t)
;;括号匹配,显示行号
(global-hl-line-mode 1)
;;显示当前行(使当前行颜色不同)-
(setq kill-ring-max 200)
;;撤销的缓存开大点200吧!
(setq default-cursor-type 'bar)
;;光标为竖线(防止光标闪烁,在菜单的options里有!)
(setq default-tab-width 4)
;;默认tab宽度为 4
(setq c-default-style "awk")
;;缩进风格(考场居然失败了QAQ
(set-frame-parameter (selected-frame) 'alpha (list 85 50))
;;透明度(一边敲代码一边看题还是舒服多了)(前一个数字表示你选中这个页面是的透明度,后一个数字是你没选中此页面)
(setq default-frame-alist'(
(vertical-scroll-bars)
(width . 200)
(height . 43)
(background-color . "black")
(foreground-color . "grey")
(cursor-color . "gold1")
(mouse-color . "gold1")
(tool-bar-lines . 0)
(menu-bar-lines . 1)
)
);;初始设置:宽度,高度,背景,字体,光标颜色,以及是否有菜单工具栏
注意事项:
1. 不要弄太多配置,考场容易码错
2. NOIP会提前20分钟入场,这段时间可以码配置(如果管得不严
平时码代码添加的一些小配置:
C++(setq frame-title-format "%b by xiao-wen")
;;改变emacs标题栏的标题(特爽)
(setq x-select-enable-clipboard t)
;;允许emacs和外部其他程序的粘贴(很好用
(setq auto-save-mode nil)
;;自动保存模式
(set-face-foreground 'region "gold1")
(set-face-background 'region "gray15")
;;(区域)选择的背景和主题
;;(set-face-foreground 'highlight "white")
(set-face-background 'highlight "gray15")
;; 设置语法高亮显示的背景和主题
;;(set-face-foreground 'secondary-selection "gray")
;;(set-face-background 'secondary-selection "darkblue")
;;(二次选择)的背景和选择(去掉分号使用
(defun up-slightly () (interactive) (scroll-up 3))
(defun down-slightly () (interactive) (scroll-down 3))
(global-set-key [mouse-4] 'down-slightly)
(global-set-key [mouse-5] 'up-slightly)
;;上下滚动时不会太快(一次只跳三行,极舒服)
(defun my-c-mode-auto-pair ()
(interactive)
(make-local-variable 'skeleton-pair-alist)
(setq skeleton-pair-alist '(
(\( ? _ ")")
(\[ ? _ "]")
(\' ? _ "'")
({ \n > _ \n ?} >)))
(setq skeleton-pair t)
(local-set-key (kbd "(") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "'") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "[") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "{") 'skeleton-pair-insert-maybe))
(add-hook 'c-mode-hook 'my-c-mode-auto-pair)
(add-hook 'c++-mode-hook 'my-c-mode-auto-pair)
;;自动补全右边的部分.包括<>, "", '', (), //, [] , {}等等。
;;这里我只写了括号(大中小都有)和引号
(custom-set-variables
'(column-number-mode t)
'(cua-mode t nil (cua-base))
'(display-time-mode t)
'(inhibit-startup-screen t)
'(show-paren-mode t)
'(tool-bar-mode nil))
(custom-set-faces
'(default ((t (:family "Ubuntu Mono" :foundry "unknown" :slant normal :weight normal :height 143 :width normal)))))
(auto-insert-mode)
(setq auto-insert-directory "~/.emacs.d/mytemplates/")
(setq auto-insert-query nil)
(define-auto-insert "\." "moban.cpp")
(electric-pair-mode t)
;;这个是部分emacs自带的(有时间字体的基础配置
其他:
C++;;(setq inhibit-startup-message t)
;;启动画面关闭
;;(c-set-style "stroustrup")
;;(c-toggle-auto-state)
;;(c-toggle-hungry-state)
;;(setq c-basic-offset 4)
;;(imenu-add-menubar-index)
;;(which-function-mode)))
;;把C++语言风格设置为stroustrup风格
;;http://www.mamicode.com/info-detail-1633534.html
;;这里再提供一个大佬的eamcs,挺全的,可以看看
提醒一下:语句要去掉前面两个分号使用
以上代码直接复制到配置可以正常运行!