Emacs Frame and buffer

本文介绍了Emacs中的核心概念——帧(frame)、窗口(window)和缓冲区(buffer)。Emacs允许同时编辑多个缓冲区,并通过窗口和帧进行显示。Emacs的窗口术语和大多数应用不同,其缓冲区不绑定到特定窗口或帧。文章详细讲解了如何创建、删除、切换和保存缓冲区,以及如何操作窗口和帧。提供了键盘快捷键和命令,如C-x b用于切换缓冲区,C-x 2用于垂直分割窗口,C-x 5 2创建新帧等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

One of the most universally features of Emacs is the ability to edit multiple buffers at once and to display more than one buffer using windows and frames.

Conceptually, Emacs is different from most applications in two important ways. First, its window terminology is different. Second, Emacs buffers are not tied to windows or frames, unlike most applications.

Frame: a separate GUI window

window: a portion of the current Emacs display.

但是框架跟窗口都是用来显示buffer.一般我们都会把文件跟窗口关联起来。一般我们还是比较喜欢只用一个Emacs frame然后通过C-x b进行buffer互切。


How many buffers are active in Emacs

1:the buffer list C-x C-b

2: The buffer menu(active buffers and commands for navigating them)

3: buffer Pop-up menu (hold down Ctrl and click left mouse button)


when you start Emacs,it generate two buffers

*Messages* :accumulate messages from its startup and from the mini-buffer.

*scratch*  :just a temporary scratch-pad where you can type, but wont save unless using C-x C-w


C-x b  The default buffer is the buffer that most recently disappeared.


deleting buffers

Deleting doesn't put you at risk of losing changes, if you have changed(associated with a file). Emacs ask if you will save the change

1:delete a buffer is such a basic operation that is on the Emacs tool-bar, the X symbol

2:C-x k  for kill-buffer, Emacs show the buffer name, type another name if the one being displayed is not you want to delete.

3:M-x kill-some-buffers  Emacs ask you about deleting each buffer.


Saving Multiple Buffers

C-x C-s  saving buffer,也就时相当于保存修改到所关联的file

C-x s    save-some-buffers  y for yes, n for no, ! no more asking . save this buffer and no more.


Read-only buffers

The file you just want to browse through Emacs, to prevent touching the keyboard accidentally from happening

C-x C-q  you'll notice percent signs(%%)appear on the left side. asterisks(**)indicate modification. this command toggles the buffer's read-only status.


Working with the Buffer list

C-x C-b -> buffer list then you can use a set of one-character command to work with the buffers listed.

d or k  D appears in the first column, then press X (execute) to delete. if connected with files. Emacs will ask you first.

u       unmark the buffer, such as D will disappear.

s       S appears in the first column, this is to save buffer. you can repeat this command, then press X to execute.

%       buffer's status from read-write to read-only

1       display the buffer in a full-screen window

q       quit buffer list

Windows

as you add more windows, the older ones shrink. The screen is like a pie, you can cut it into many pieces. but the more pieces you cut, the smaller they have to be.


Creating Horizontal Windows

C-x 2 for split-window-vertically

C-x 4 f   C-x C-f

C-x 4 b  C-x b


Creating Vertical or side-by-side windows

C-x 3 split the window vertically.当你这么做以后,因为空间变小了,一行并不能够放下以前的东西,这个时候会有个箭头表示后面还有。

C-x < 看右边的东西

C-x > 看左边的东西


Move Between Windows

C-x o o stands for other.进行切换,如果现在一个屏中有很多个buffer,他会按照从左向右,从上到下,进行切换。


Enlarging and shrinking windows

因为在你分屏的时候都是均分的,所以会造成你想工作的区域也越来越小。

C-x ^ make window taller

C-x } make window wider

C-x { shrink-window

C-u C-x 后面跟上面[^{}]中任何一个,然后它的变化将是以4行或4列为单位

Frame

C-x 5 2  make-frame,Emacs will make a new frame containing the current buffer.

创建的它一般会放在当前buffer的上面,但是如果它完全覆盖了当前的buffer,你可以在.emacs进行设置,让他们分开(tell them apart)。Subsequent Frame

Frame name : 默认开启时叫Emacs@system name, 如果创建了multiple frame,Frame name display buffer name as their title.

C-x 5 b  move to a buffer and put it in a new frame.

C-x 5 o  move between Frames

C-x 5 0  delete-frame  delete current frame

C-x 5 f  find-file-other-frame

C-x 5 b  swith-to-buffer-other-frame



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值