sams emacs 24 hour 读书笔记4

Hour 6: Editing Several Files at Once

一次编辑多个文件

使用C-x b可以更改buffer,C-x C-b可以查看buffer列表

使用C-x C-b后,可以看到是个buffer的管理界面


这个buffer,我们可以选择,删除,和保存文件,但是不能在这个buffer里插入文本,在这个buffer里,最重要的快捷键是

  1. 1 ,按下1会把当前所在行的buffer唯一的显示在frame中
  2. o 或者C-o ,按下这个快捷键,被选择的buffer或显示在别的window里,这两个快捷键的唯一区别是o把光标移动到了另外的window,而C-o不会这么做我们可以看下按下C-o的效果
  3. d、C-d和x,按下d会把当前行所在的buffer标记为删除,并把光标移动到下一行,而C-d会标记删除,移动到上一行,值得一提的是,这个buffer并没有被立即删除,为了执行删除操作,需要按下x(执行)
  4. s,按下s会把当前的buffer标记为保存,同样的,也没有被立即保存,只是被标记而已

上面的第一列D表示这个buffer已被标记为删除,第二列的S表示已被标记为保存

Traveling Through the Buffers

正常情况下,如果总在两个buffer中进行切换的话,那么使用C-b RET就可以进行互换了,但是倘若有很多的文件需要进行切换的话就需要书上的yic-buffer.el
在.emacs中插入
(load-library "yic-buffer")
默认情况下,这个library的绑定C-x C-p到上一个buffer,C-x C-n绑定到下一个buffer
当然也可以自行定义,如果想要绑定到Ctrl-Page-Up and Ctrl-Page-Down,则要在.emacs中写
(global-set-key [(control prior)] 'bury-buffer) 
(global-set-key [(control next)] 'yic-next-buffer) 

iswitchb
快速输入一个buffer的名字(Naming a Buffer in an Easier Way)
GNU Emacs20以上的版本在.emacs里直接加入:
(iswitchb-mode 1)
然后在emacs里按C - x, b就会看到好多个buffer的名字,这些buffer的名字会随着你输入的名字而更新。这样就不需要按Tab键来补全了。
如果想忽略一下buffer的名字,例如:*scratch*等等。可以加入下面的代码:

(setq iswitchb-buffer-ignore '("^ " "*Messages*" "*scratch*" "*Compile-Log*" "*GNU Emacs*"))

C-s 左移备选项,C-r右移备选项

Saving the Buffer List

保存buffer列表

The library called desktop does in fact do this.

This library makes Emacs save the list of buffers and some information about these buffers to a file. Each directory can contain one such file (its name is.emacs.desktop). When Emacs is started it checks whether such a file is located in the startup directory and, if this is the case, the state is read from this file.

To make it work, insert the following lines into your .emacs file:


(load "desktop") 
(desktop-load-default) 
(desktop-read) 
When a desktop has been loaded, it is saved to the same file on exit, but the first time you need to tell it to save. To do this, press M-x and type desktop-save.

Working with Windows and Frames

C-x 2
水平分割frame

C-x 3
垂直分割


C-x 1
删除别的window
C-x 0
删除当前活动window

Basic Frame Movement: Creation and Deletion

C-x 5 2
创建一个frame
C-x 5 0
删除一个frame
C-x 5 o
选中另外一个frame

Dedicated Frames (用的较少)

Two functions exist in the sams-lib.el that make it possible to create such dedicated frames:

  • sams-find-file-dedicated-frame, which asks for a filename, loads this file into a buffer, and shows this buffer in a dedicated frame.

  • sams-switch-buffer-dedicated-frame, which asks for a buffer name and loads this buffer into a dedicated frame.

Emacs can also place buffers in dedicated frames itself. This can be useful for the buffer containing help or info files. To tell Emacs which buffers it must create dedicated frames for, insert something such as the following into your .emacs file.


(setq special-display-buffer-names '("*Help*" "*Apropos*" 
                                     "*compilation*" "*grep*" "*igrep*")) 



评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值