硬包和软包的区别?

发布于 2024-07-10 11:14:25 字数 82 浏览 3 评论 0原文

我正在编写一个文本编辑器。 在查看其他文本编辑器后,我注意到其中许多都指的是“软”换行与“硬”换行。 有什么不同? 我似乎无法通过搜索找到答案。

I am in the process of writing a text editor. After looking at other text editors I have noticed that a number of them refer to a "soft" versus "hard" wrap. What is the difference? I can't seem to find the answer by searching.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

下壹個目標 2024-07-17 11:14:25

硬换行会在文本中的换行点插入实际换行符,而软换行则实际文本仍位于同一行,但看起来像是分为几行。

A hard wrap inserts actual line breaks in the text at wrap points, with soft wrapping the actual text is still on the same line but looks like it's divided into several lines.

风苍溪 2024-07-17 11:14:25

文本编辑器通常会自动将文本自动换行成带有硬换行符的段落,但如果您稍后返回并编辑/添加/删除单词,则文本重新排列成漂亮的段落的情况不太常见。 (您可以在 emacs 中使用 Mq 手动执行此操作。)

这相当烦人,因为像我这样的强迫症患者随后必须返回并在适当的点手动重新插入硬中断。

另一方面,软包装很烦人,因为大多数命令行工具都使用基于行的差异(版本控制是我最注意到的地方)。 如果您有一个 1/3 页的段落经过软包装并修复了拼写错误,则基本上不可能在常规 diff 输出或类似输出中看到更改的位置。

It's usual for text editors to auto-wrap text into paragraphs with hard newlines, but it's less common for the text to be re-flowed into a nice paragraph if you come back later and edit/add/remove words later on. (You can do this manually in emacs with M-q.)

This is rather annoying, since obsessive compulsive people like me then go back and have to manually re-insert the hard breaks at the appropriate points.

On the other hand, soft wrapping is annoying because most all command line tools use line-based diff-ing (version control is where this becomes most noticeable to me). If you've got a 1/3-page paragraph that's soft wrapped and fix a typo, it's basically impossible to see where the change is in a regular diff output or similar.

又爬满兰若 2024-07-17 11:14:25

soft :以表单形式提交时,文本区域中的文本不会换行。 这是默认的

hard :在表单中提交时,文本区域中的文本会换行(包含换行符)。 使用“hard”时,必须指定 cols 属性

参考:W3Schools

soft : The text in the textarea is not wrapped when submitted in a form. This is default

hard : The text in the textarea is wrapped (contains newlines) when submitted in a form. When "hard" is used, the cols attribute must be specified

Reference: W3Schools

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文