前言
最初接触emacs是因为org-mode,后来学习lisp又把玩了几把。
我还是无法放弃Lisp,就从emacs开始吧,虽然之前配置过很多次,但都没有很好的记录过。
首先当然是下载了,http://www.gnu.org/software/emacs/,目前最新版是25.2
解压运行runemacs.exe就行,终端下emacs -nw。安装之后我们简要配置一下。
入门配置
参考 http://www.jianshu.com/p/b4cf683c25f3
配置文件及其加载过程:通常,emacs会优先加载.emacs,如果找不到,并且存在文件夹.emacs.d,会尝试加载其中的init.el
HOME路径
===============================================
将如下配置copy到$HOME/.emacs.d,重命名为init.el
;; copy this file to $HOME/.emacs.d/, and rename it to "init.el". (in windows, the default HOME directory is "C:\Users\x\AppData\Roaming", you can find out that by typping "C-x d ~/ <RET>" in emacs.)
(setenv "HOME" "C:/emacs") ;; you can change this dir to the place you like
(require 'package)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))
(when (< emacs-major-version 24)
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
(add-to-list 'package-archives '("melpa-stable" . "http://melpa-stable.milkbox.net/packages/"))
(package-initialize)
(load "~/.emacs.d/init.el")
=================================================
接下来的才是正式的配置文件,即~/.emacs.d/init.el,以下为新手配置,大神勿喷。
主要设置外观、字体、编码、tab、缩进等。
(load-theme 'misterioso' t)
(set-frame-position (selected-frame) 56 28)
(set-frame-width (selected-frame) 96)
(set-frame-height (selected-frame) 30)
(setq inhibit-startup-message t)
(setq gnus-inhibit-startup-message t)
(setq frame-title-format "emacs@%b")
(setq visible-bell t)
(tool-bar-mode 0)
;;(menu-bar-mode 0)
;;(scroll-bar-mode 0)
(set-face-foreground 'region "white")
(set-face-background 'region "#6B8E23")
(setq-default cursor-type 'bar)
(set-cursor-color "green")
(mouse-avoidance-mode 'animate)
(mouse-wheel-mode t)
(setq initial-major-mode 'text-mode)
(setq default-major-mode 'text-mode)
;;(add-hook 'text-mode-hook 'turn-on-auto-fill)
(fset 'yes-or-no-p 'y-or-n-p)
(setq x-select-enable-clipboard t)
(setq mouse-yank-at-point t)
(global-font-lock-mode t)
(global-hi-lock-mode 1)
(setq line-number-mode t)
(setq column-number-mode t)
(global-linum-mode t)
(setq linum-format "%d ")
(toggle-truncate-lines t)
(global-hl-line-mode 1)
(show-paren-mode t)
(setq show-paren-style 'parenthesis)
(setq track-eol t)
(setq scroll-margin 3
scroll-step 1
scroll-conservatively 10000)
(display-time-mode 1)
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(setq display-time-interval 10)
;;(setq display-time-format "%m-%d %A %H:%M")
(setq time-stamp-active t)
(setq time-stamp-warn-inactive t)
(add-hook 'write-file-hooks 'time-stamp)
(setq make-backup-files nil)
(setq auto-image-file-mode t)
(auto-compression-mode 1)
(ido-mode t)
;(setq default-directory "e:/Project")
(setq backward-delete-char-untabify-method 'hungry)
(global-set-key "\C-m" 'newline-and-indent)
(global-set-key (kbd "C-<return>") 'newline)
(set-language-environment "utf-8")
(setq default-buffer-file-coding-system 'utf-8)
;;font settings
;;not use 'default-font' or 'default-frame-alist'
;; Setting English Font
(set-face-attribute
'default nil :font "Consolas 13")
;; Chinese Font
(dolist (charset '(kana han symbol cjk-misc bopomofo))
(set-fontset-font (frame-parameter nil 'font)
charset
(font-spec :family "Microsoft Yahei" :size 14)))
;;disable indent-relative and enable the tab-to-tab-stop function instead
;;you can call whitespace-mode to see tabs,spaces, trails.
(global-set-key (kbd "TAB") 'tab-to-tab-stop) ;;in every mode
(setq-default indent-tabs-mode nil) ;;spaces only
(setq-default tab-width 4)
(setq tab-stop-list (number-sequence 4 120 4))
================================================
操作入门
建议先熟悉菜单操作,阅读帮助文档。
按键说明:
系统操作
C-h C-h 帮助
C-x C-c 退出
C-g 取消命令
M-! 外部命令
光标操作
p n b f 上下左右
C-a/e 行首/尾
M-</> 开头/末尾(需按shift)
M/C-v 前/后翻页
M-g g 跳转到行
编辑
C-x u 撤销(或者C-_,需按shift)
C-d 删除光标后字符(类似delete)
C-k 移除从当前光标到行尾
C-y 召回(类似粘贴)
C/M-w 剪切/复制
C-x h 全选
C-s/r 搜索
缓冲区
C-x C-b 列出缓冲区
C-x b 切换缓冲区
C-x s 保存缓冲区
窗口
C-x 0 关闭
C-x 1 关闭其它
C-x 2 水平分割
C-x 3 垂直分割
C-x o 切换
C-x ^ 加高
C-x {/} 宽度调节
================================================
插件
================================================