本文来自多方查询,目前我仍是第一次使用emacs,因此有不少问题在emacs高手看来可能会比较幼稚,可是这并不影响我把这个神之编辑器以及怎样用这个神之编辑器写CMakeLists.txt的方法分享出来html
此处不现说明c++
刚刚安装好的emacs会自动建立备份文件,能够在家目录中新建一个.emacs 文件,加入如下内容
git
;;禁止备份 (setq make-backup-files nil)
参考自:http://blog.csdn.net/flytomysky/article/details/7096561github
行号:shell
;; 显示行号 (require 'linum) (setq linum-format "%3d ") ;对全部文件生效 (add-hook 'find-file-hooks (lambda () (linum-mode 1)))
PS:根据我在网上查的资料看来,emacs显示行号这个功能,在22版本以前好像要下载插件,个人版本是24.4.1,在加入上面的配置后,重启emacs,显示行号没有问题bootstrap
参考自:http://samson7b.iteye.com/blog/1522473vim
其实cmake的源码包中就已经自带了emacs和vim的插件,路径在源码包中的Auxiliary文件夹中bash
➜ cmake-3.3.1 ls Auxiliary CMakeLogo.gif CTestConfig.cmake Modules bootstrap cmake_uninstall.cmake.in CTestCustom.cmake.in README.rst CMakeCPack.cmake CompileFlags.cmake DartConfig.cmake Source CMakeCPackOptions.cmake.in configure doxygen.config Templates CMakeGraphVizOptions.cmake CONTRIBUTING.rst Help Tests CMakeLists.txt Copyright.txt Licenses Utilities ➜ cmake-3.3.1 ls Auxiliary bash-completion cmake-indent.vim cmake.m4 cmake-syntax.vim cmake-help.vim CMakeLists.txt cmake-mode.el ➜ cmake-3.3.1
将其中的cmake-mode.el复制到~/.emacs.d/plugins/cmake中,在.emacs中添加以下配置app
;; cmake 自带的emacs插件,能够语法高亮 (setq load-path (cons (expand-file-name "/home/laolang/.emacs.d/plugins/cmake") load-path)) (require 'cmake-mode) (setq auto-mode-alist (append '(("CMakeLists\\.txt\\'" . cmake-mode) ("\\.cmake\\'" . cmake-mode)) auto-mode-alist))
参考自:http://blog.csdn.net/csfreebird/article/details/7197392编辑器
使emacs能够自动提示[PS:这里的自动提示其实须要开启company的功能,因为我是emacs新手,因此不知道如何修改]
company的github地址:https://github.com/company-mode/company-mode
我将其放在:~/.emacs.d/plugin/company
在.emacs中添加以下配置
;company,ctrl+tab启动,能够自动提示CMakeLists.txt,同时c-mode,c++mode下也有自动提示 (add-to-list 'load-path "~/.emacs.d/plugins/company") (autoload 'company-mode "company" nil t) (setq company-idle-delay nil) (add-hook 'c-mode-hook '(lambda () (company-mode))) (add-hook 'c++-mode-hook '(lambda () (company-mode))) (global-set-key [(control tab)] 'company-complete-common)
在使用company的自动提示功能以前,须要M-x company-mode,看到Company mode enabled以后,就可使用Ctrl + Table使用其自动提示功能了,固然前提是你要输入至少一个字符才行
效果: