ido-mode
1 启动ido-mode
添加如下配置
(setq ido-enable-flex-matching t)(setq ido-use-filename-at-point 'guess)(setq ido-everywhere t) (ido-mode 1)
2 操作
输入部分名称,就会自动筛选匹配的文件/buffer. 若候选项是由多个单词用空格分隔组成的,则可用直接输入每个单词的首字母缩写,也能匹配该候选项.例如输入`cgf`能够匹配"*Customize Group: Foobar *"
使用<-和->在待选项中切换选择.
使用向上,下键切换上次/下次的文件/buffer
直接使用C-f 和C-b 切换文件/buffer选择模式
按回车直接选择第一个匹配项
其他命令 #+CAPTION:一般命令
Keybinding | Description | Available In |
C-b | Reverts to the old switch-buffer completion engine | Buffers |
C-f | Reverts to the old find-file completion engine | Files |
C-d | Opens a dired buffer in the current directory | Dirs / Files |
C-a | Toggles showing ignored files (see ido-ignore-files) | Files / Buffers |
C-c | Toggles if searching of buffer and file names should ignore case. (see ido-case-fold) | Dirs / Files / Buffers |
TAB | Attempt to complete the input like the normal completing read functionality | Dirs / Files / Buffers |
C-p | Toggles prefix matching; when it’s on the input will only match the beginning of a filename instead of any part of it. | Files |
C-s / C-r | Moves to the next and previous match, respectively | All |
C-t | Toggles matching by Emacs regular expression. | All |
Backspace | Deletes characters as usual or goes up one directory if it makes sense to do so. | All (but functionality varies) |
C-SPC / C-@ | Restricts the completion list to anything that matches your current input. | All |
// | 直接跳到根目录,若在windows下则为driver目录 | Files |
~/ | 直接跳到HOME目录 | Files / Dirs |
M-d | Searches for the input in all sub-directories to the directory you’re in. | Files |
C-k | Kills the currently focused buffer or deletes the file depending on the mode. | Files / Buffers |
M-m | Creates a new sub-directory to the directory you’re in | Files |
当用ido-find-file打开一个文件时,会把该文件所在目录的所有文件信息缓存起来,该缓存起来的目录被称为Work Directory. work Directory会被记录在ido-work-directory-list变量中.
当在当前目录下查找不到符合条件的文件时,在等待一段时间后,ido会自动从work directory list中搜索符合条件的文件
#+CAPTION:Work Directory Commands
键绑定 | 描述 |
---|---|
M-n / M-p | 切换到下一个/上一个work directory |
M-k | 从list中删除当前work directory |
M-s | 在所有的work directory list中搜索匹配当前输入的文件名 |
3 配置
变量`ido-use-filename-at-point`
根据光标所在值猜测默人要打开的文件名的方法,nil表示不猜测
(setq ido-use-filename-at-point 'guess)
变量`ido-use-url-at-point`
类似变量`ido-use-filename-at-point`,但是把光标所在的值作为是url
变量`ido-create-new-buffer`
当用C-x b输入一个新buffer时,默认情况下ido会提示你再按一次回车确认新建buffer.
该变量的可选值为
'alway 不提示,直接新建
'prompt 提示用户确认
'never 不新建
设置显示可选项的顺序
变量`ido-file-extensions-order`
;; 空格表示没有扩展名的文件,t表示所有未列出扩展名的其他文件的以默认方法排序(setq ido-file-extensions-order '(".org" ".txt" ".py" ".emacs" ".xml" ".el" ".ini" ".cfg" ".cnf" "" t))
设置隐藏某些可选项
Variable Name | Description |
---|---|
ido-ignore-buffers | Takes a list of buffers to ignore in C-x b |
ido-ignore-directories | Takes a list of directories to ignore in C-x d and C-x C-f |
ido-ignore-files | Takes a list of files to ignore in C-x C-f |
ido-ignore-extensions | 是否忽略变量`completion-ignored-extensions`中的文件 |
completion-ignored-extensions | Completion ignores file names ending in any string in this list.It ignores directory names if they match any string in this list which ends in a slash. |
ido-work-directory-list-ignore-regexps | 符合该列表的目录不放入work directory中 |
ido-auto-merge-delay-time | 当在当前目录下查找不到符合条件的文件时,在等待一段时间后,ido会自动从work directory list中搜索符合条件的文件,该等待的时间由该变量决定,单位为秒 |