简体   繁体   English

如何在Emacs中自动换行?

[英]How to word wrap in Emacs?

如何配置emacs以便换行不会在单词中间中断?

If you want to emulate the behavior of an editor like Notepad, you might want to turn on visual line mode. 如果要模拟记事本等编辑器的行为,可能需要打开视觉线模式。 While setting word-wrap will cause line wrapping at word boundaries, any action you take on a line (eg, moving up/down or killing) will still respect the newline character. 虽然设置自动换行将导致换行在单词边界处,但您在一行上执行的任何操作(例如,向上/向下移动或查杀)仍将尊重换行符。 Visual line mode will treat each display line as though it had a newline at the end. 可视线模式将每条显示行视为最后有一个换行符。

(visual-line-mode t)

Line to add in .emacs file: 要添加到.emacs文件中的行:

(global-visual-line-mode t)

Can you specify what kind of wrapping are you talking about ? 你能指出你在说什么样的包装吗?

Mx toggle-truncate-lines disable allow you to disable visually line breaking. Mx toggle-truncate-lines disable允许您禁用视觉断行。

Mx auto-fill-mode + Mq allow you to wordwrap for real a pre-existing paragraph. Mx自动填充模式 + Mq允许您对真实的预先存在的段落进行自动换行。

Add this to your init file: 将其添加到您的init文件中:

(setq-default word-wrap t)

Alternatively, press Ch v word-wrap in Emacs and follow the "customize" link near the end. 或者,在Emacs中按Ch v word-wrap ,然后按照末尾附近的“自定义”链接。

I discovered longlines-mode only recently (I think I was spelunking through the emacs Info docs). 我最近才发现了longlines-mode(我想我正在浏览emacs Info文档)。 It wraps as you would expect in other UI editors' word-wrap feature. 它像其他UI编辑器的自动换行功能一样包装。 It's especially useful when I'm reading or writing free text with no newlines (a la Word) without the ugly mid-word wrapping that happens when you use Mx toggle-word-wrap . 当我正在阅读或编写没有换行符的自由文本(一个单词)而没有使用Mx toggle-word-wrap行时发生的丑陋的中间词包装时,它尤其有用。

http://www.emacswiki.org/emacs/LongLines http://www.emacswiki.org/emacs/LongLines

my config: 我的配置:

(setq longlines-wrap-follows-window-size t)
(global-set-key [(control meta l)] 'longlines-mode)

id got to it first. id首先得到它。 You can read more about similar features at 你可以在这里阅读更多相关功能

http://www.emacswiki.org/emacs/LineWrap http://www.emacswiki.org/emacs/LineWrap

As a new user you might benefit from reading the page as there are some subtleties and history to deal with about word-wrap and long lines. 作为一个新用户,您可能会从阅读页面中受益,因为有一些细微之处和历史需要处理有关自动换行和长行的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM