让你的Emacs像vi一样高亮 “#if 0 ... #endif"
来源:互联网 发布:淘宝宝贝长图要上几张 编辑:程序博客网 时间:2024/05/22 07:46
1. 编辑你的.emacs配置文件
vi ~/.emacs 或 emacs ~/.emacs
2. 将以下函数粘贴到你的.emacs文件内
;;Highlight #if 0 to #endif (defun my-c-mode-font-lock-if0 (limit) (save-restriction (widen) (save-excursion (goto-char (point-min)) (let ((depth 0) str start start-depth) (while (re-search-forward "^\\s-*#\\s-*\\(if\\|else\\|endif\\)" limit 'move) (setq str (match-string 1)) (if (string= str "if") (progn (setq depth (1+ depth)) (when (and (null start) (looking-at "\\s-+0")) (setq start (match-end 0) start-depth depth))) (when (and start (= depth start-depth)) (c-put-font-lock-face start (match-beginning 0) 'font-lock-comment-face) (setq start nil)) (when (string= str "endif") (setq depth (1- depth))))) (when (and start (> depth 0)) (c-put-font-lock-face start (point) 'font-lock-comment-face))))) nil) (defun my-c-mode-common-hook () (font-lock-add-keywords nil '((my-c-mode-font-lock-if0 (0 font-lock-comment-face prepend))) 'add-to-end)) (add-hook 'c-mode-common-hook 'my-c-mode-common-hook) ;;Highlight end
3. 重新启动Emacs看看^_^
- 让你的Emacs像vi一样高亮 “#if 0 ... #endif"
- 让你的Emacs像VS一样方便
- 让Source Insight像EMACS一样工作
- vi像文本一样使用, vim显示行号、语法高亮、自动缩进的设置
- 让你的程序像office一样有位小助手.
- 让你的程序像系统命令一样运行
- 让你的PDF像百度文库一样在线预览
- Emacs快捷键列表 让我怎么不喜欢你,神一样的emacs
- #if 0 #endif的含义
- #if 0 .........#endif的使用
- #if 0 #endif 的用处
- #if 0 ....#endif的作用
- #if 0 #endif的作用
- “#if 0/#if 1 ... #endif”的作用
- #if 0/#if 1 ... #endif”的作用
- “#if 0/#if 1 ... #endif”的作用
- “#if 0/#if 1 ... #endif”的作用
- “#if 0/#if 1 ... #endif”的作用
- 我的个人站——记录我学习的探索和疑惑
- 让Div内层将DIV外层撑开
- [Java] 一个关于i++ 的问题
- VC++ warning C4786 详解
- 是否怀念这些日子
- 让你的Emacs像vi一样高亮 “#if 0 ... #endif"
- 【郭林专刊】JSP中JSTL提供的函数标签EL表达式操作字符串的方法
- IT面试真经
- PHP中 Classes/Object 函数
- 你经历过吗?
- ASP.NET变量的作用域
- 《java编程思想》第一章 笔记
- 三条命令解决Windows 7无法启动问题
- use Emakefile to compile erlang project