爲Emacs項添加字符串值html
名稱 | 數據 |
---|---|
HOME | D:\emacs-26.1 |
增長環境變量D:\emacs-26.1node
添加倉庫git
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
初始化packagegithub
(package-initialize)
配置文件init-mytheme.elwindows
(add-to-list 'custom-theme-load-path "your path") (load-theme 'solarized t)
配置文件init-mythememarkdown
(setq molokai-theme-kit t) (add-to-list 'custom-theme-load-path "your path") (load-theme 'molokai t)
編碼設置ide
(set-language-environment 'UTF-8) (set-locale-environment "UTF-8") (set-default-coding-systems 'utf-8)
中英文等寬設置函數
(defun set-font (english chinese english-size chinese-size) (set-face-attribute 'default nil :font (format "%s:pixelsize=%d" english english-size)) (dolist (charset '(kana han symbol cjk-misc bopomofo)) (set-fontset-font (frame-parameter nil 'font) charset (font-spec :family chinese :size chinese-size)))) (set-font "Dejavu Sans Mono" "WenQuanYi Zen Hei Mono" 14 14)
如下全部插件都可使用如下命令安裝:工具
M-x package-install RET xxx RET
markdown-mode支持emacs markdown編輯,效果預覽須要pandoc工具支持。
插件markdown-toc用於自動生成目錄。字體
配置
(autoload 'markdown-mode "markdown-mode" "Major mode for editing Markdown files" t) (add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode)) (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode)) (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode)) (autoload 'gfm-mode "markdown-mode" "Major mode for editing GitHub Flavored Markdown files" t) (add-to-list 'auto-mode-alist '("README\\.md\\'" . gfm-mode)) ;; 需安裝pandoc (setq markdown-command "D:/Program/Pandoc/pandoc.exe")
快捷指令
指令 | 功能 |
---|---|
C-c C-s b | 加粗 |
C-c C-s i | 傾斜 |
C-c C-s c(C) | code |
C-c C-s 1~6(或 h) | 標題 |
C-c C-s f | 腳註 |
C-c C-l | 插入連接 |
C-c C-i | 插入圖片 |
C-c C-s C-h | 查詢幫助 |
C-c C-s t | 插入表格 |
指令(with pandoc) | 功能 |
---|---|
C-c C-c m | 顯示對應html代碼 |
C-c C-c p | preview |
C-c C-c e | export |
C-c C-c v | export & preview |
C-c C-c o | open |
C-c C-c C-h | help |
快捷指令
M-x markdown-toc-generate-toc ;; 生成目錄樹 M-x markdown-toc-refresh-toc ;; 更新目錄樹 M-x markdown-toc-delete-toc ;; 刪除目錄樹
配置方法
(eval-after-load "org" '(require 'ox-md nil t))
導出md方法
C-c C-e m
模擬vi操做體驗的emacs插件,寫代碼更爽。
配置
(require 'evil) (evil-mode 1)
快捷方式
指令 | 功能 |
---|---|
C-z | emacs模式和evil模式間切換 |
配置
(require 'auto-complete) (require 'auto-complete-config) (global-auto-complete-mode t) ;; 文本模式下啓動補全功能 (add-to-list 'ac-modes 'text-mode) (ac-config-default) (setq ac-auto-start 4) ;; pos-tip 幫助閃爍 ;;(require 'pos-tip) ;;(setq ac-quick-help-prefer-pos-tip t) ;; quick-help (setq ac-use-quick-help t) (setq ac-quick-help-delay 1.0) (setq ac-dwim t) (setq ac-trigger-commands (cons 'backward-delete-char-untabify ac-trigger-commands)) ;; fuzzy (setq ac-fuzzy-enable t) ;; menu ;;(setq ac-menu-height 12) ;;(set-face-background 'ac-candidate-face "lightgray") ;;(set-face-underline 'ac-candidate-face "darkgray") ;;(set-face-background 'ac-selection-face "steelblue")
pos-tip在這個環境下效果不好,顯示的幫助內容閃爍
auto-complete插件和company插件衝突,在彈出菜單時可能形成顯示混亂
模糊匹配fuzzy插件
(setq ac-fuzzy-enable t) ;; 不起做用 M-x ac-fuzzy-complete ;; 能夠起做用,但沒用
爲C、C++、C#、Perl、Python等語言設置代碼片斷。
(require 'yasnippet) ;; 使用Ctrl-c k做爲惟一的觸發快捷鍵 (define-key yas-minor-mode-map (kbd "<tab>") nil) (define-key yas-minor-mode-map (kbd "TAB") nil) (define-key yas-minor-mode-map (kbd "C-c k") 'yas-expand) (setq yas-snippet-dirs '("~/.emacs.d/Mysnippets")) (yas-global-mode t)
建立snippet
C-c & C-n (M-x yas-new-snippet) ;; 建立新snippet C-c C-c ;; 保存snippet
典型例子
# contributor: test <test@qq.com> # name: __---__ # -- __${init}__
# expand-env :expand environment,爲變量賦值的列表(相似於let的變量賦值),
在展開代碼段時,它可用於覆蓋變量值
# note: 從官網說明獲取,方便舉例 # name: ASCII home # expand-env: ((yas-indent-line 'fixed) (yas-wrap-around-region 'nil)) # -- welcome to my X humble / \ home, / \ $0 / \ /-------\ | | | +-+ | | | | | +--+-+--+
嵌入elisp代碼
使用反引號`將elisp代碼嵌入到模板中,代碼會在snippet展開時執行
/*c-mode example,示例取自官網*/ #ifndef ${1:_`(upcase (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`_H_} #define $1 $0 #endif /* $1 */
Mirrors
將帶有佔位符的製表位稱爲field,一個field能夠有許多mirrors。
當更新一個field,相應field全部的mirrors都會更新
begin {${1:test}} $0 end{$1}
snippet實踐
# -*- mode: snippet -*- # name: main # key: c_main # -- /*${1: test} begin*/ /* C語言main函數snippet,輸入c_main而後C-c k便可 */ int main(${2:int args}, ${3:char *argv[]}) { $0; return 0; }/*$1 end*/
注:若光標被導航到了$0,沒法使用S-TAB向後導航了。
ido配置
(ido-mode 1) (setq ido-separator "\n") (setq ido-enable-flex-matching t)
semx配置
(require 'smex) (smex-initialize) (global-set-key (kbd "M-x") 'smex) (global-set-key (kbd "M-X") 'smex-major-mode-commands) ;; This is your old M-x. (global-set-key (kbd "C-c C-c M-x") 'execute-extended-command)
操做
M-number
自定義配置
(require-package 'solarized-theme) (require 'solarized) (defun init-mytheme-light () "My solarized child theme." (custom-theme-set-faces theme-name `(default ((,class (:background ,base03)))) )) (deftheme init-mytheme "The light variant of the Solarized color theme") (create-solarized-theme 'light 'init-mytheme 'init-mytheme-light)
操做
M-x fci-mode
emacs自帶IRC客戶端,啓動指令:
M-x erc
minibuffer會提示操做步驟:
注:步驟1-2可按默認配置,步驟3-4需自定義