Emacs - 笔记整理 (草稿)
Table of Contents
1 Setup 安装
- OSX : Emacs For Mac OS X
- Linux : 用包管理器安装
2 Package Manager 包管理器
- M-x package-list-packages
- use-package
3 Coonfig 配置
- 个人喜好 : ~/.emacs.d/init.el -(org-babel)-> ~/.emacs.d/config.org
- 配置文件(下载): init.el config.org
4 Basic 基础
4.1 UI 用户界面
- Menu 菜单栏 : 屏幕顶部突出显示的条
- Frame 框架
- Window 窗口
- Buffer 缓冲区 : 关联文件
- Window 窗口
- Mode Line 模式行 (状态栏) : 每个窗口中 横贯底部的高亮条 提供当前缓冲区的信息
- Echo Area : 模式行下面 底部的区域 显示相关信息
Mode Line
4.2 Mode 模式
- 主要模式 major-mode : 主要的编辑行为 仅用于当前缓冲区 仅有一个活动的主模式
- 次要模式 minor-mode : 提供了一些与任何特定的主要模式无关的特性或功能 可多个
4.3 Keybinding 键绑定
组合键
- Ctrl (C)
- Meta (M)
- 输入 Meta
- Alt
- Esc (按下 Esc, 松开, 再按其它键)
- Ctrl-[ 代替 Esc (通过网络运行 Emacs, 无法使用 Esc 和 Alt 键时)
- 输入 Meta
For Mac
;; Fn -> hyper : H (setq ns-function-modifier 'hyper) ;; Cmd -> meta : M (setq ns-command-modifier 'meta) ;; Opt -> super : S (setq ns-option-modifier 'super)
设置
- Global : global-(set|unset)-key
- Local : local-(set|unset)-key
Assist
- bind-key
Config
(require 'bind-key)
Example
(bind-key "C-c x" 'my-ctrl-c-x-command) ;; override all minor modes (bind-key* "<C-return>" 'other-window) ;; Unbind (unbind-key "C-c x" some-other-mode-map) ;; Keymap (bind-key "C-c x" 'my-ctrl-c-x-command some-other-mode-map) ;; Multiple bind (bind-keys* ("C-o" . other-window) ("C-M-n" . forward-page) ("C-M-p" . backward-page)) ;;-| add keys into a specific map (bind-keys :map dired-mode-map ("o" . dired-omit-mode) ("a" . some-custom-dired-function)) ;;-| set up a prefix map (bind-keys :prefix-map my-customize-prefix-map :prefix "C-c c" ("f" . customize-face) ("v" . customize-variable))
4.4 Command 命令
每一个命令 == 一个功能(Elisp函数)
退出 Emacs | confirm-kill-emacssave-buffers-kill-terminal | C-x C-c |
取消 | keyboard-quit | C-g 或 ESC ESC ESC |
执行 命令 | execute-extended-command | M-x |
求值 Elisp | eval-expression | M-: (C-u .. : 结果插入缓冲) |
4.5 Help 帮助
- Tutorial : C-h t
- Manual : info-emacs-manual
==
C-h r- Online : Emacs manual
当前模式|变量|函数|键绑定|符号
describe-mode C-h m describe-varible C-h v describe-function C-h f describe-bindings C-h b describe-symbol C-h o 通过键盘 输入一个键绑定
describe-key-briefly C-h c describe-key C-h k - 命令历史
- M-x list-command-history
Key bindings
4.6 Buffer 缓冲区
- 打开-文件
- find-file
==
C-x C-f - find-file-read-only
==
C-x C-r - 替换: find-alternate-file
==
C-x C-v (替换缓冲区关联的文件)
- find-file
- 切换
- switch-to-buffer
==
C-x b (-> Helm-mini) - switch-to-buffer-other-(window|frame)
==
C-x (4|5) b - list-buffers
==
C-x C-b (-> helm-buffers-list) - (previous|next)-buffer
==
C-x (left|right)
- switch-to-buffer
- 杀死
- kill-buffer
==
C-x k - M-x kill-(some|matching)-buffers
- M-x clean-buffer-list (未修改>=3天)
- kill-buffer
- 保存
- 全部: save-some-buffers
==
C-x s - 当前: save-buffer
==
C-x C-s
- 全部: save-some-buffers
- 另存为
- write-file
==
C-x C-w
- write-file
- 重命名
- M-x rename-(buffer|uniquely)
- 只读
- read-only-mode
==
C-x C-q
- read-only-mode
- 恢复
- M-x revert-buffer (恢复到上一次存盘时)
- M-x recover-file (从自动保存恢复)
- M-x recover-session
- 重定位
- recenter-top-bottom
==
C-l
- recenter-top-bottom
- Indirect Buffers : shares the text of some other buffer
- M-x (make|clone)-indirect-buffer
- clone-indirect-buffer-other-window
==
C-x 4 c
Assist
- 缓冲列表: Helm
- C-x b
=>
Helm-mini - C-x C-b
=>
helm-buffers-list
- C-x b
4.7 Window & Frame 窗口和框架
Window
- 打开-文件
- find-file-other-window
==
C-x 4 f - find-file-read-only-other-window
==
C-x 4 r
- find-file-other-window
- 划分-垂直|水平
- split-window-(below|vertically)
==
C-x 2 - split-window-(right|horizontally)
==
C-x 3
- split-window-(below|vertically)
- 关闭
- 当前: delete-window
==
C-x 0 - 其它: delete-other-windows
==
C-x 1 - 当前窗口及其缓冲区: kill-buffer-and-window
==
C-x 4 0
- 当前: delete-window
- 滚动
- scroll-other-window
==
C-M-v
- scroll-other-window
- 调整大小
- enlarge-window
==
C-x ^ - (enlarge|shrink)-window-horizontally
==
C-x (}|{) - shrink-window-if-larger-than-buffer
==
C-x - - 平衡-所有可见窗口大小: balance-windows
==
C-x +
- enlarge-window
Frame
- 打开-文件
- find-file-other-frame
==
C-x 5 f - find-file-read-only-other-frame
==
C-x 5 r
- find-file-other-frame
- 新建
- make-frame-command
==
C-x 5 2
- make-frame-command
- 切换
- other-frame
==
C-x 5 o - switch-to-buffer-other-frame
==
C-x 5 b
- other-frame
- 删除
- 当前: delete-frame
==
C-x 5 0 - 其它: delete-other-frames
==
C-x 5 1
- 当前: delete-frame
Assist
4.8 Server 服务
- 开启服务 : M-x server-start
初始文件 <<
(server-start)
- 客服端 : emacsclient
- -t <filename> : open a new frame on the terminal
- -c : open a new X frame
- -n, –no-wait : Don't wait for the server to return
5 Begining 开始
入门 Emacs 是很简单的事 网络上能够搜索出大量的入门文章和视频
所以呢 我不打算 做一些重复的工作
换个角度来试试看
编辑器 用来做什么? 编辑文本 写代码 写书 收发邮件 浏览网页 看图片 看视频 …
从 编辑文本 开始 : 需要什么?
- Move|Jump 移动或跳转 :
- 要在 Buffer中移动 : 字符 单词 行
- 跳到 不同的 Window中 或 Frame中
- Edit 编辑
- 选中 : 选择需要编辑的部分文本
- 插入
- 删除
- 复制 粘贴 剪切
- 撤销 重做
- 处理 : 执行一些特定的功能 如 转换大小写
- Search 搜索
- Repeat 重复
- Assist
- Manipulating pairs : smartparens
- Narrowing
- Folding
Emacs 是基于文本的 所以 对文本的操作 可以贯穿各种场景 然后根据特定的需要 使用不同的模式 提供更多的功能
- 主模式
- Org
- Dired
- 次要模式
- abbrew
再到 我要写代码 建立开发环境 需要什么?
- Completion : company
- Syntax Checking : flycheck
- Format (style, highlight, indent )
- Navigation (tag, definition, symbols)
- Code Templates & Snippets : yasnippet
- Project : progectile, Speedbar
- Doc
- Enhancement Edit
- Assist
- Compilation
- Debugging
特定的语言 又需要什么?
- Common lisp
- Slime
- Enhancement Edit : paredit, lispy
- Completion : company-slime
- C
6 Move 移动 & Jump 跳转
光标的定位 (屏幕可视范围内)
Buffer
- 左右
- C-b|f == (backward|forward)-char
- M-b|f == (backward|forward)-word
- 上|下
- C-p|n == (previous|next)-line
- 行-首|尾
- C-a|e == (beginning|end)-of-line
- 句子-首|尾
- M-a|e == (backward|forward)-sentence
- 段落-首|尾
- M-{|} == (backward|forward)-paragraph
- 翻页-上|下
- M|C-v == PgUp|PgDn | scroll-(up|down)-command
- 缓冲区-首|尾
- M-<|> == (beginning|end)-of-buffer
- 到本行第一个非空字符
- M-m == back-to-indentation
- N-行
- M-g (g|M-g) == goto-line
- 当前缓冲区可视区域-(Top|Center|Bottom)
- M-r == move-to-window-line-top-bottom
Window
- C-x o == other-window
Frame
- M-x select-frame-by-name
Assist
- Wind Move
- M-x windmove-(left|right|up|down)
- Ace Window
- M-x ace-window (Me: == S-o)
- Avy
- M-x avy-goto-(char|word-1|line)
Supplement
;; 设置 sentence-end 可以识别中文标点 (setq sentence-end "\\([。!?]\\|……\\|[.?!][]\"')}]*\\($\\|[ \t]\\)\\)[ \t\n]*")
7 Edit 编辑
- 选中 (标记) : 选择需要编辑的部分文本
- 插入
- 删除 剪切 复制 粘贴
- 撤销 重做
- 处理 : 执行一些特定的功能 如 转换大小写
- 特性 : 矩形区块
7.1 Mark 标记
选中 需要编辑的部分文本
- 标记
- 点
- C-(<SPC>|@) == set-mark-command (激活)
- C-<SPC> C-<SPC> (不激活 但进入标记环)
- 段落
- M-h == mark-paragraph
- 缓冲区
- C-x h == mark-whole-buffer
- Mouse shift-selection
- Shift-<Mouse>
- 点
- 标记环 (Mark Ring : 标记的点 进入 标记环) [Global|Local]
- 最后标记点
- C-u C-<SPC> (当前缓冲)
- C-x C-<SPC> == pop-global-mark
- 列表
- 最后标记点
- 互换位置-插入点和标记点
- C-x C-x == exchange-point-and-mark
Special
- 标记 表达式
- C-M-@ == mark-sexp
- 标记 定义
- C-M-h == mark-defun
Assist
- 标记环列表: Helm
- M-x helm-mark-all-rings | helm-[global]-mark-ring
- expand-region : er/expand-region
= C-
Supplement
整行
(defun xt3/sel-cur-line () (interactive) (set-mark (line-end-position)) (beginning-of-line)) (bind-key "C-x M-h" #'xt3/sel-cur-line)
7.2 Insert 插入
Input 输入
- 可见的(图形字符) : a..z , 1..0, !..?
- 控制字符 : <SPC>, <RET>, <TAB>, <DEL>, <ESC>, <F1>, <Home>, <LEFT>
- 插入空白行 : <RET> | C-j | C-o
- 修饰键 : <Control>, <META>
- 输入 对应 命令
- 非键盘 : mouse(鼠标) (一般作为定位 特殊模式 拖拽绘制字符)
- 引用插入
- C-q == quoted-insert
- 不可见(非图形字符)
- <Ret>, C-l(分页符)
- 033 Enter (Ascii 八进制) = f
- Unicode
- C-x 8 RET
- 速记 : C-x 8 C-h £
- ∑ (2211) ⤶ (2936)
Assist
- Input Method 输入法
- 内置
- 触发 : toggle-input-medthod == C-\
- 切换 : select-input-medthod == C-u C-\ | C-x Ret C-\
- 示例 :
Tex α x₃ X³
\alpha α \Gamma Γ \rightarrow → \Leftarrow ⇐ \oplus ⊕ \int ∫ x_3 x₃ v^x vˣ
greek-babel αΑ Γγ η
Αα Ββ Γγ Δδ Εε Ζζ Ηη Θθ Ιι Κκ Λλ Μμ Aa Bb Gg Dd Ee Zz Hh Jj Ii Kk Ll Mm Νν Ξξ Οο Ππ Ρρ Σσς Ττ Υυ Φφ Χχ Ψψ Ωω Nn Xx Oo Pp Rr Ssc Tt Uu Ff Qq Yy Ww
- 内置
- 使用操作系统的 输入法 或 其它工具
- Abbrev mode
- zhw -> hello world hello world
- 补全
- company
- auto-complete
- yasnippet
- yas-insert-snippet == s-i
- 来源 : 文件 | 其它缓冲
- C-x i == insert-file
- insert-buffer
7.3 删除 剪切 复制 粘贴
- 删除(delete) | 剪切(kill)
- 区别 : kill 会把kill掉内容放到 kill ring 里
- 字符|词 - 左|右
- delete-backward-char == <Del>
- delete-char == C-d
- —
- backward-kill-word == (C|M)-<Del>
- kill-word == M-d
- 行 - 右|左|整行
- 右: kill-line == C-k
- 左: M-0 C-k
- 整: kill-whole-line (-> whole-line-or-region == C-w)
- 句
- kill-sentence == M-k
- backward-kill-sentence == C-x <DEL>
- 区域
- kill-region == C-w (-> whole-line-or-region)
- 复制-区域
- kill-ring-save == M-w (-> whole-line-or-region)
- 粘贴 (从 Kill ring (剪切环))
- 最近一个: yank == C-y
- yank-pop == M-y
- 指定位置: (C-u|M-) [Num] C-y
Special
- 表达式 (exp) "exp" exp
- C-M-k == kill-sexp
Assist
- Kill Ring : Helm
- helm-show-kill-ring == M-y
- whole-line-or-region config : 区域激活 则应用到区域 否则 应用到当前行
- Copy Kill Move(Kill-[Goto]-Paste)
- 到字符之前
- 右: M-z [char] == zap-to-char
- 左: M– M-z
- 连续-空格
- delete-horizontal-space == M-\
- 空白行 (位置相关: 一个到无 | 多个到一个 | 跟随的全部)
- delete-blank-lines == C-x C-o
- 重复行
- delete-duplicate-lines (keeps first)
- C-u : keeps last
- C-u C-u : only adjacent lines (邻近)
- C-u C-u C-u : retains repeated blank lines
- delete-duplicate-lines (keeps first)
7.4 Undo/Redo 撤销 重做
7.5 Multiple 多重
- rectangle 矩形区块
- 插入
- 空格: open-rectangle == C-x r o
- 字符串: M-x string-insert-rectangle
- 行号: rectangle-number-lines == C-x r N
- C-u : set start number and format
- 替代
- 空格: clear-rectangle == C-x r c
- 字符串: string-rectangle == C-x r t
- 删除
- delete-rectangle == C-x r d
- 空格: M-x delete-whitespace-rectangle
- 剪切 | 复制 | 粘贴
- C-x r k == kill-rectangle
- C-x r M-w == copy-rectangle-as-kill
- C-x r y == yank-rectangle
- 插入
- Keyboard Macro 键盘宏
Assist
7.6 Other 其它
- 缩进
- 按上一行的格式: indent-region
= M-C-\ =
<Tab> - 区域: indent-rigidly
= C-x <Tab> =
C-x C-i
- 按上一行的格式: indent-region
- 行操作
- 开新
- open-line == C-o
- newline-and-maybe-indent == C-j
- 分割
- split-line == M-C-o
- 连接-前|后
- delete-indentation == M-^ (反向: C-u ..)
- 开新
- 调换-前|后
- transpose-(chars|words) == (C|M)-t
- 转换-大小写
- (capitalize|uppercase|downcase)-word == M-(c|u|l) (反向: M– ..)
- (upcase|downcase)-region == C-x C-(u|l)
- Narrowing : 当前缓冲 进入部分编辑 不影响缓冲其它部分
- 进入: narrow-to-(region|page|defun) == C-x n (n|p|d)
- org-narrow-to-(subtree|block|element) == C-x n (s|b|e)
- 退出: widen == C-x n w
- 进入: narrow-to-(region|page|defun) == C-x n (n|p|d)
7.6.1 Align 对齐
- align (align-rules-list)
- align-(current|entire|newline-and-indent)
- align-regexp (C-u ..)
Assist
7.6.2 Sort 排序
- 按-行|列|段|页
- sort-(lines|columns|paragraph|pages)
- paragraph <- paragraph-start, paragraph-separate
- 反序: C-u ..
- sort-(lines|columns|paragraph|pages)
- sort-numeric-fields (base: sort-numeric-base)
- sort-fields (第几字段: C-u [N] | M-[N])
- 正则表达式 : sort-regexp-fields
- word : () \1
- words : (+) \1
- 反序
- M-x reverse-region
- 忽略大小写 : sort-fold-case = t
8 Search 搜索 & Replace 替换
Search
- isearchn (Incremental search)
- 前|后 (重复-切换搜索到的词)
- isearch-(forward|backward) == C-(s|r)
- isearch-(forward|backward)-regexp == C-M-(s|r)
- isearch-forward-(word|symbol) == M-s (w|_)
- isearch-forward-symbol-at-point == M-s .
- Activated (C-s ..)
- Paste : C-y
- History : M-n|p
- 大小写敏感 : M-c
- C-w (光标处到下一个词的词尾)
- C-(s|r) ( 同向: 重复上一次搜索; 反向: 切换搜索方向)
- 非增量 : RET
- Regex : M-r
- 前|后 (重复-切换搜索到的词)
- occor
- M-s o == occur
- -> Occur buffer
- e : occur-edit-mode : Edit current Occur buffer
- exit : C-c C-c
- next|previous : M-g (n|p)
- repeat : C-x z
- next|previous line : C-n|p
- beginning|end of buffer : <|>
- refresh : g
- Jump to match : o
- Jump to match but point remainon Occur : C-o
- help : h
- quit : q
- multi-occur (multiple buffers)
- M-x multi-occur
- M-x multi-occur-in-matching-buffers
- M-s o == occur
- grep
- M-x grep
- Asynchronously : M-x lgrep
- M-x grep-find | find-grep
Replace
- 所有: replace-(string|regexp)
- 问询
- query-replace == M-%
- query-replace-regexp == C-M-%
- 选项
- 退出 : <Enter>|q
- 替换当前 : <Spc>|y
- 替换-所有 : !
- 跳过 : <Del>|n
- 退回-到前一次替换 : ^
- 替换当前 且 退出 : .
- 替换当前 且 光标移动到此处 且 退出 : ,
- 撤销-前一个|所有 : u|U
- 递归编辑 : C-r
- 退出 : C-M-c
- 删除-这个匹配 并 进入递归编辑 : C-w
- 退出-递归编辑 和 问询 : C-]
- 编辑-替换的字符串 : E
Assist
- Swiper : Ivy-Swiper Swiper-helm
- C-s ..
- Paste : C-y | M-y(Kill Ring)
- Next|Previous : C-(n|p)
- C-s ..
- helm-swoop == M-i
- (M-[N] 显示周围行)
- 多缓冲: helm-multi-swoop == C-c M-i
- 所有缓冲: helm-multi-swoop-all
- Edit mode : C-c C-e
- Ag : helm-ag
- Multiple cursors config kbd
Special
- imenu : helm-imenu
- helm-semantic-or-imenu == C-c h i
- Search engines : helm-surfraw == C-c h s
- brew install surfraw
- Project : Projectile
9 Repeat 重复
- 多次运行同一个命令
- universal-argument == C-u [N] (缺省次数: 4)
- digit-argument == (C|M)-[N]
- C-u [C-u]* (4n)
- 上一条命令 (一次或多次)
- repeat == C-x z … z
- 复杂命令
- repeat-complex-command == C-x ESC ESC | C-x M-:
Assist
10 Assist 辅助
10.1 Information 信息
- 词数
- count-words-region
==
M-= (缓冲: C-u ..) - M-x count-words (缓冲|区域)
- count-words-region
- 行数
- M-x count-lines-region
- 字符信息
- what-cursor-position
==
C-x = (编码 第几个字符 第几列) - M-x describe-char (详细信息)
- what-cursor-position
10.2 Keyboard Macro 键盘宏
- 开始|结束
- (start|end)-kbd-macro
==
C-x (|)==
<F3>|<F4> - 追加: C-u C-x (
- (start|end)-kbd-macro
- 执行
- call-last-kbd-macro
==
C-x e==
<F4> - M-x (Macro Name) | helm-execute-kmacro
- call-last-kbd-macro
- 终止
- C-g
- 命名
- M-x name-last-kbd-macro
10.3 Abbrev 缩写 (待整理..)
- 添加
- 全局: add-global-abbrev
==
C-x a g - 当前主要模式: add-mode-abbrev
==
C-x a l - inverse-add-(global|mode)-abbrev
==
C-x a i (g|l) - M-x define-(global|mode)-abbrev
- 前缀
- 0 : region as expansion
- C-u [N] : N words
- 全局: add-global-abbrev
- 删除
- Arg: C-u -
- 全部: M-x kill-all-abbrevs
- 扩展
- abbrev-prefix-mark
==
M-' - expand-abbrev
==
C-x a e - M-x expand-region-abbrevs
- M-x unexpand-abbrev
- abbrev-prefix-mark
- 查看和编辑
- M-x list-abbrevs (C-u [N] .. : local, N:次数)
- M-x edit-abbrevs
- 保存
- M-x write-abbrev-file <RET> file <RET>
- M-x read-abbrev-file <RET> file <RET>
- M-x define-abbrevs
- M-x insert-abbrevs
10.4 Register 寄存器 (待整理..)
寄存器 : 存储 文本 矩形区块 位置 值 设置
- View
- M-x view-register <RET>
- Jump
- jump-to-register == C-x r j
- Position
- Save: point-to-register == C-x r <SPC>
- Text|Rectangle
- Save: copy-[rectangle]-to-register == C-x r (s|r) (C-u .. : copy-to and del)
- Insert: insert-register == C-x r i
- Text
- Append: M-x append-to-register <RET>
- increment-register == C-x r +
- Prepend: M-x prepend-to-register <RET>
- Append: M-x append-to-register <RET>
- Frame&Window Configuration
- Save
- window-configuration-to-register == C-x r w
- frameset-to-register == C-x r f
- Restore: C-x r j (C-u .. : del frame invisible)
- Save
- Number
- Save: number-to-register == C-u [N] C-x r n
- Increment: C-u [N] C-x r +
- Insert: insert-register == C-x r i
- Keyboard Macro
- Save: kmacro-to-register == C-x C-k x
- Exe: C-x r j
10.5 Bookmark 书签 (待整理..)
书签 : 保存缓冲区中位置
- 设置-光标位置
- bookmark-set == C-x r m
- bookmark-set-no-overwrite == C-x r M
- 移动到-指示的位置
- bookmark-jump == C-x r b
- 显示-书签列表
- list-bookmarks == C-x r l
- 删除
- M-x bookmark-delete
- 重命名
- M-x bookmark-rename
- 保存 加载
- 到默认文件: bookmark-save
- 新文件: bookmark-write
- 加载: bookmark-load
- 插入
- 文件内容: bookmark-insert
- 文件名字: bookmark-insert-location
10.6 Other 其它
Highlight 高亮
- 光标所在行
- hl-line-mode (当前缓冲) config
自动加载外部修改过的文件
- global-auto-revert-mode
自动保存
- M-x auto-save
- 重开: M-1 ..
11 Special Mode
11.1 Dired (待整理..)
Dired (Directory Edit) Config
打开
- dired
==
C-x d==
C-x C-f [Dir] - dired-other-(window | frame)
==
C-x (4 | 5) d - list-directory
==
C-x C-d
Mode
- 退出: q
- 执行 Shell 命令
- dired-do-(async)-shell-command
==
! | (&)
- dired-do-(async)-shell-command
- 刷新
- revert-buffer
==
g - dired-do-redisplay
==
l
- revert-buffer
- 排序-时间|文件名-(默认按文件名排序)
- s == dired-sort-toggle-or-edit
- C-u s
- c : last modification time.
- u : access time.
- S : file size.
- X : file extension.
- 移动
- 下|上
- Space
= C-n =
n - Del
= C-p =
p
- Space
- 子目录: dired-(next | prev)-dirline
==
> | < - Jump : dired-goto-file
==
j - 父目录: dired-up-directory
==
^
- 下|上
- 打开-文件
- dired-find-file
==
<RET>==
f - dired-find-file-other-window
==
o - dired-display-file
==
C-o (光标不动) - 只读: dired-view-file
==
v- C-c
==
q // 返回目录清单窗口 - s // search
- Enter // 前进到下一行
- = // 显示光标在哪一行
- e // 编辑文件
- C-c
- dired-find-file
- 标记
- dired-mark
==
m- 后面的 N 个: (N) m
- Regex: dired-mark-files-regexp
==
% m - 去掉: dired-unmark-(backward)
==
u | <del> - 去掉所有: dired-unmark-all-marks
==
U
- dired-mark
- 执行
- dired-do-flagged-delete
==
x
- dired-do-flagged-delete
- 新建
- dired-create-directory
==
+ - S // 符号链接
- H // 硬链接
- dired-create-directory
- 复制
- dired-do-copy
==
C- (N) C // 将复制光标位置上的文件和其后N个
- dired-do-copy
- 删除
- 立即: dired-do-delete
==
D - 待删标记: dired-flag-file-deletion
==
d
- 立即: dired-do-delete
- 重命名或移动
- R
- 修改-权限|用户|用户组|时间戳
- M // Mode
- O // owner
- dired-do-chgrp
==
G - T // Timestamp
- 压缩|解压缩-文件
- dired-do-compress
==
Z (已压缩 则 解压缩) - dired-do-compress-to ~== c
- dired-do-compress
- 搜索
- dired-do-search
==
A - dired-isearch-filenames
==
M-s f C-s - dired-isearch-filenames-regexp
==
M-s f M-C-s
- dired-do-search
- 查询替换
- dired-do-query-replace
==
Q
- dired-do-query-replace
11.2 Org
11.3 Shell
11.4 Git
Assist
- Magit
- magit-status
==
C-c g - Help: ?
- magit-status
12 Programming
12.1 C
12.2 Lisp
Common Lisp
- Slime Config
Doc
(setq common-lisp-hyperspec-root (concat "file://" (expand-file-name "~/.emacs.d/HyperSpec/"))) (setq common-lisp-hyperspec-symbol-table (concat common-lisp-hyperspec-root "Data/Map_Sym.txt")) (use-package w3m) (setq browse-url-browser-function '(("/HyperSpec" . w3m-browse-url) ("." . browse-url-default-browser)))
Assist
12.2.1 Lispy (待整理..)
View
- lispy-(narrow | widen)
==
(N | W) - lispy-view
==
v (重定位到第一行)
Move & Jump
- List: lispy-(backward | forward)
==
[ | ] - l | C-3 : lispy-right : up-list
- ) : lispy-right-nostring == lispy-right (except self-inserts in strings and comments)
- h : lispy-left
- j : lispy-down
- k : lispy-up
- f : lispy-flow
- d : lispy-different (Switch side of sexp)
- b : lispy-back (previous position in lispy-back history)
- —
- —
- z : lispy-knight
- leftmost parens on each line 每行最左边的括号(上下移动) : k j
- C-e : lispy-move-end-of-line
- ? case1 inside string : Move to the end of the string.
- case2 otherwise : Return starting position.
- -— k
[ h f l) ] j
Position
- A : lispy-beginning-of-defun
- — Ace —
- q : lispy-ace-paren
- Q : lispy-ace-char
- a : lispy-ace-symbol
- - : lispy-ace-subword
Nav
- — Definition —
- F : lispy-follow (jump to definition)
- region is active -> marked symbol
- Otherwise -> first symbol in current sexp
- M-. : lispy-goto-symbol
- D|M-, : pop-tag-mark (jump back, M-* in default Emacs)
- F : lispy-follow (jump to definition)
- — Tag —
- g|G : lispy-goto (whole directory | current file)
- 0g|ogp : lispy-goto-projectile
Select & Mark
- C-M-, : lispy-mark (smallest comment|string|list includes point, repeated -> expand region)
- m : lispy-mark-list
- M-m : lispy-mark-symbol
- i : lispy-mark-car (Region Active)
Edit
- C-q : insert a single character frome the pair
- " : lispy-quotes
- " | " -> "\"\""
- region -> "region"
- C-u " : "word" -> word
- ; : lispy-comment
- Undo : u == lispy-undo
- Newline : C-8 == lispy-parens-down
- (foo|) -> (foo) (|)
- — Pair —
- ( == lispy-parens
- Prefix:
- M-n( num -> M-1( : |() -> (()) M-2( : |() () -> (() ()) …
- M-0( rest -> (foo |bar baz quux) -> (foo (|bar baz quux))
- M–( line rest -> (foo |bar baz quux) -> (foo (|bar baz) quux)
- Prefix:
- { : lispy-braces
- } : lispy-brackets
- ( == lispy-parens
- — Copy,Cut,Paste —
- C-, : lispy-kill-at-point (最内层括号和其内容)
- H : lispy-ace-symbol-replace
- n : lispy-new-copy (Copy sexp|region -> kill ring)
- C-y : lispy-yank
- P : lispy-paste
- C-k : lispy-kill
- M-k : lsipy-kill-sentence
- C-d : lispy-delete
- DEL : lispy-delete-backward
- M-d : lispy-kill-word
- M-DEL : lispy-backward-kill-word
- — List —
- c : lispy-clone
- / : lispy-splice (list -> parent list)
- (|(a) (b) (c)) -> (a |(b) (c))
- > : lispy-slurp
- < : lispy-barf
- r : lispy-raise
- R : lispy-raise-some
- w : lispy-move-up
- s : lispy-move-down
- oh : lispy-move-left
- ol : lispy-move-right
- ok : lispy-up-slurp
- oj : lispy-down-slurp
- t : lispy-teleport (Move sexp|region -lispy-ace-paren-> location)
- C : lispy-convolute
- (a b (c (d e) |(move)) f g) -> (c (d e) (a b (move) f g))
- — Transform —
- ; : lispy-comment
- xb : lispy-bind-variable
- M-m to finish
- xu : lispy-unbind-variable
- xl | C-4 l : lispy-to-lambda (defun -> lambda)
- xd | C-4 d : lispy-to-defun (lambda -> defun)
- xi : lispy-to-ifs (cond -> if)
- xc : lispy-to-cond (if -> cond)
- xf : lispy-flatten (Inline function|macro)
- S : lispy-stringify (sexp -> string)
- —
- i : special-lispy-tab (otherwise: Indent and prettify code)
- O : (sexp -> one line)
- M : (sexp -> multiple lines)
- M-o : lispy-string-oneline (muli-line-string -> one line (message "foo"|))
- — Muli-Cursor —
- M-i : lispy-iedit (多光标编辑)
Search
- y : lispy-occur
Compile Eval Debug Test
- e : lispy-eval (region|sexp, result in minibuffer)
- E : lispy-eval-and-insert
- xr : lispy-eval-and-replace
- xh : lispy-describe (function|variable)
- p : lispy-eval-other-window (Eval sexp in context of other window)
- — Edebug —
- xe : lispy-edebug
- 2xe : eval current defun instead
- xj : lispy-debug-step-in
- Z|q : lispy-edebug-stop
- xe : lispy-edebug
- — Test —
- T : lispy-ert
Help Assist
- digit-argument
- [>0] : - [arg] (99j)
- 0 : all
- M– : current line
- x | C-4 : prefix
- o : lispy-other-mode
- h : lispy-move-left
- l : lispy-move-right
- j : lispy-down-slurp
- k : lispy-up-slurp
- SPACE
- g
- a : special-lispy-goto-def-ace
- b : special-pop-tag-mark
- d : special-lispy-goto (当前文件所有符号)
- e : special-lispy-goto-elisp-commands
- f : special-lispy-follow
- j : special-lispy-goto-def-down
- l : special-lispy-goto-local
- p : special-lispy-goto-projectile
- r : lispy-goto-recursive | special-lispy-goto-recursive
- q : special-lispy-quit
- — Help —
- C-1 : lispy-describe-inline
- C-2 : lispy-arglist-inline
— Outline —
;;* Level 1 ;;** Level 2 ;;*** Level 3
- I : lispy-shifttab (Toggles on/off an org-mode-like outline.)
- J : lispy-outline-next (on outline : j)
- K : lispy-outline-prev (on outline : k)
- i : lispy-tab (on outline)
- M-RET : lispy-meta-return (new outline)
- M-R|L : lispy-meta-right|left
- — Project —
- V : lispy-visit (Visit another file within this project)
- Default: projectile or find-file-in-project
- V : projectile-find-file
- 2V : projectile-find-file-other-window.
- Customize: lispy-visit-method
- Default: projectile or find-file-in-project
- V : lispy-visit (Visit another file within this project)
- — Ediff —
- xB : lispy-store-region-and-buffer
- B : lispy-ediff-regions
13 Hydra
聚合功能 更方便输入 并且 辅助记忆差 手速低 的我
13.1 Window
(global-set-key (kbd "<f2>") (defhydra f2-fun (:color pink :hint nil) " Window ^ Resize ^ ^ Move ^ ^Split^ ^Delete ^^^^^^^^----------------------------------------------------------------- _e_: enlarge ^_i_^ _v_:| _dw_:del-current _s_: shrink _j_ _l_ _x_:- _da_:ace-del _E_: enlarge-<> ^_k_^ _|_:>move _do_:del-other _S_: shrink-<> _ws_:swap ___:Vmove ^ ^_db_:kill-buf _bw_: balance ^<Jump>^ ^^^^ _df_:del-frame ^ ^ _a_:ace _f_:to-frame " ("e" #'enlarge-window) ("s" #'shrink-window) ("E" #'enlarge-window-horizontally) ("S" #'shrink-window-horizontally) ("bw" #'balance-windows) ;; Move ("j" #'windmove-left) ("i" #'windmove-up) ("l" #'windmove-right) ("k" #'windmove-down) ("ws" ace-swap-window) ;; Jump ("a" ace-window :exit t) ("f" #'select-frame-by-name :exit t) ;; Spilt ("|" (lambda () (interactive) (split-window-right) (windmove-right))) ("_" (lambda () (interactive) (split-window-below) (windmove-down))) ("v" #'split-window-right) ("x" #'split-window-below) ;; Delete ("da" ace-delete-window) ("dw" delete-window) ("do" delete-other-windows :exit t) ("db" kill-this-buffer) ("df" delete-frame :exit t) ;; Misc ("t" transpose-frame "-<->|") ("nf" new-frame "New-frame" :exit t) ("z" #'text-scale-adjust "Zoom" :exit t) ;; ("q" nil "Quit" :color blue)))
13.2 MC
(global-set-key (kbd "C-S-c") (defhydra hydra-mc (:columns 5) "multiple-cursors" ("ll" mc/edit-lines "lines") ("le" mc/edit-ends-of-lines "end-lines") ("j" mc/mark-next-like-this "next") ("uj" mc/unmark-next-like-this "un-n") ("J" mc/skip-to-next-like-this "skip-n") ("s" #'mc/mark-next-like-this-symbol "symbols-n") ("k" mc/mark-previous-like-this "prev") ("uk" mc/unmark-previous-like-this "un-p") ("K" mc/skip-to-previous-like-this "skip-p") ("aa" mc/mark-all-like-this "all") ("A" mc/mark-all-dwim "dwim") ("aw" #'mc/mark-all-words-like-this "word") ("as" mc/mark-all-symbols-like-this-in-defun "symbols-in-def") ("r" #'mc/mark-all-in-region-regexp "region-regexp") ;; Quit ("q" nil "Quit" :color blue))) ;; ("i" mc/insert-numbers) ;; ( "h" mc-hide-unmatched-lines-mode) ;; ( "dr" mc/reverse-regions) ;; ( "ds" mc/sort-regions)
14 Config
14.1 Ace Window
(use-package ace-window :config (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)) (ace-window-display-mode) :bind ("S-o" . ace-window))
14.2 Avy
(use-package avy :bind (("C-;" . 'avy-goto-char) ;; ("C-'" . 'avy-goto-char-2) ("M-g g" . 'avy-goto-line) ;; ("M-g e" . 'avy-goto-word-0) ("M-g w" . 'avy-goto-word-1)))
14.3 Undo Tree
(use-package undo-tree :diminish undo-tree-mode :config (global-undo-tree-mode))
14.4 whole line or region
(use-package whole-line-or-region :diminish whole-line-or-region-mode :config (whole-line-or-region-mode t) (make-variable-buffer-local 'whole-line-or-region-mode))
14.5 Mutiple cursors
(use-package multiple-cursors :config (setq mc/always-run-for-all t)) (bind-key "M-<down-mouse-1>" 'mc/add-cursor-on-click) (unbind-key "M-<down-mouse-1>" redshank-mode-map)
14.6 Highlight Line
(global-hl-line-mode 1)
14.7 Dired
14.9 Slime
(use-package slime :config (require 'slime-autoloads) ;; (setq inferior-lisp-program "~/ccl/dx86cl64") (slime-setup '(slime-fancy)) (when (executable-find "sbcl") (add-to-list 'slime-lisp-implementations '(sbcl ("sbcl") :coding-system utf-8-unix))) (when (executable-find "ccl64") (add-to-list 'slime-lisp-implementations '(ccl ("ccl64") :coding-system utf-8-unix))) (setq slime-default-lisp 'ccl) ; select : M-- M-x slime ccl (setq slime-net-coding-system 'utf-8-unix) ;; We tell slime to not load failed compiled code (setq slime-load-failed-fasl 'never) (setq slime-complete-symbol*-fancy t))
14.11 Lispy
(use-package lispy :config ;; slime-repl (defun xt3/newline-and-indent () (interactive) (if (eq major-mode 'slime-repl-mode) (slime-repl-newline-and-indent) (lispy-newline-and-indent))) (substitute-key-definition 'lispy-newline-and-indent 'xt3/newline-and-indent lispy-mode-map) ;; Colon no space (defun xt3/lisp-colon () "Insert :." (interactive) (insert ":")) (substitute-key-definition 'lispy-colon 'xt3/lisp-colon lispy-mode-map) (add-to-list 'lispy-goto-symbol-alist '(slime-repl-mode lispy-goto-symbol-lisp le-lisp)) :bind ("C-M-," . lispy-mark))