emacs-line-wrap

本文介绍了Emacs中处理过长逻辑行的两种主要方法:换行与截断,并详细讲解了Continuation Lines与Line Truncation的概念。此外还介绍了如何通过使用Visual Line Mode改善阅读体验。

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

emacs-line-wrap

emacs-line-wrap

Table of Contents

  • 1. Continuation Lines
  • 2. Line Truncation
  • 3. 注意事项

首先,这个小话题是一个大点的话题中的小分支。这个大的话题在Info里叫做
【Controlling the Display】。简单地说,本小话题是关于这个问题的:文本
的一行很长,那么,要显示这很长的一行,有两种显示策略,一种叫换行,一
种叫截断。

1 Continuation Lines

Sometimes, a line of text in the buffer-a "logical line"-is too long
to fit in the window, and Emacs displays it as two or more "screen
lines". This is called "line wrapping" or " or "continuation", and
the long logical line is called a "continued line". On a graphical
display, Emacs indicates line wrapping wrapping with small bent
arrows in the left and right window fringes. On a text terminal,
Emacs indicates line wrapping by displaying a ‘\’ character at the
right margin.

翻译就是:一行【逻辑行】1太长,窗口显示不下,Emacs就用两行或多
行来显示这一行【逻辑行】,并把自动拆分成多行这一行为叫做【line
wrapping】或【continuation】。拆分出来的这些行叫做【screen line】,
即【屏幕行】。为了明确的告诉用户Emacs进行了“拆分”这个动作,会在
这些屏幕行的窗口左右边缘显示手形图标(GUI模式)或‘\’字符(TEXT模式)。

Most commands that act on lines act on logical lines, not screen
lines. For instance, ‘C-k’ kills a logical line. As described
earlier, ‘C-n’ (‘next-line’) and ‘C-p’ (‘previous-line’) are
special exceptions: they move point down and up, respectively, by
one screen line (*note Moving Point::).

翻译一下:大多数命令是作用在【逻辑行】的,对命令的作用对象要有清楚的认识。

By default, continued lines are wrapped at the right window edge.
Since the wrapping may occur in the middle of a word, continued
lines can be difficult to read. The usual solution is to break your
lines before they get too long, by inserting newlines. If you
prefer, you can make Emacs insert a newline automatically when a
line gets too long, by using Auto Fill mode. *Note Filling::.

翻译一下:默认情况下,换行动作一般发生在窗口右边缘。但换行动作不太智
能,有时会从单词的中间拆分,影响阅读。因此,通常你可以在一行变得太长
之前,手动插入换行符,即敲击回车键,进行手动换行。当然,如果你愿意,
你也可以试试【Auto Fill Mode】,让Emacs帮你自动插入换行符,当一行变
得太长时。

Sometimes, you may need to edit files containing many long logical
lines, and it may not be practical to break them all up by adding
newlines. In that case, you can use Visual Line mode, which enables
"word wrapping": instead of wrapping long lines exactly at the right
window edge, Emacs wraps them at the word boundaries (i.e., space or
tab characters) nearest to the right window edge. Visual Line mode
also redefines editing commands such as ‘C-a’, ‘C-n’, and
‘C-k’ to operate on screen lines rather than logical lines.

翻译一下:有时候,你编辑的文档包含大量的很长的【逻辑行】,导致手动拆
行不实际。在这种情况下,你可以试试【Visual Line Mode】,它稍具智能,
在拆分的时候,如果要拆分的地方是单词,不会将单词给拆掉,而是在单词的
边界开始拆分。同时,这个模式也将部分命令的作用对象改为屏幕行。

2 Line Truncation

开头说了,显示过长的【逻辑行】有两种策略:一种叫换行,一种叫截断。截
断,就是将太长的部分隐藏。注意:无论换行还是截断,【逻辑行】内容都没
有任何变化,只是用来展示【逻辑行】的【屏幕行】有些许变动。其实,所谓
的截断,发生的非常自然,只是我们没给它一个说法而已。窗格太小,一行太
长,那么这一行就有很多内容被窗格给盖住了。Emacs里把文字被窗口给盖住
的现象,叫做【截断】。想想也是,当文字太长时,太长的部分,要么看得见,
要么看不见,即显示或隐藏,二者必居其一。因此,对太长的行来说,换行与
截断其实是必有一个会发生的。我们只需要设定一些选项,告诉Emacs,当行
太长时,是选择换行,还是选择截断,仅此而已。在作出了这个决定后,我们
再设定一些选项,告诉Emacs,如果换行的话,有哪些注意事项。如果截断的
话,有哪些注意事项。

因此,我们在查阅关于【逻辑行】显示策略的变量或函数时,首先要明确它是
针对换行的,还是针对截断的。这一点明确之后,它具体的解释就很好理解了。

3 注意事项

额外再多说几句吧。本文中所谓的太长,其实是有确切的标准的,那就是一些
诸如fill-column等参数的值。比如这个参数值是10的话,那Emacs就把10个字
符就看做太长。这里只是举个例子,真实情况是Emacs可能需要同时考虑很多
参数,才会作出最终的行动。

Footnotes:

1

就是实际的文本内容。

Created: 2017-05-13 周六 15:08

Emacs 24.5.1 (Org mode 8.2.10)

Validate

转载于:https://my.oschina.net/zhoubaojing/blog/898845

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值