CMakeLists.txt編輯器--emacs

本文來自多方查詢,目前我仍是第一次使用emacs,因此有不少問題在emacs高手看來可能會比較幼稚,可是這並不影響我把這個神之編輯器以及怎樣用這個神之編輯器寫CMakeLists.txt的方法分享出來html

1、安裝

此處不現說明c++

2、禁止備份+行號顯示

剛剛安裝好的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


3、添加CMakeLists.txt語法高亮

其實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編輯器


4、安裝company

使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使用其自動提示功能了,固然前提是你要輸入至少一個字符才行

效果:

參考自:http://blog.chinaunix.net/uid-20263484-id-110157.html

相關文章
相關標籤/搜索