打印时如何在vim中启用自动换行
我想打印一个简单的文本文档并确保单词在单词边界上换行。 我尝试了这两种方法
set linebreak
,
set wrap
但是在打印时,它只是在单词中间的右列上中断。 这可以用于打印吗?
I wanted to print a simple text document and make sure words wrap on word boundaries. I tried both
set linebreak
and
set wrap
but when printing, it just breaks on the right column in the middle of words. Is this possible for printing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在创建一个没有任何内置换行符的文本文件,因此每个段落都是一个“行”,即使使用换行符和换行集,看起来它们是多行)。 这就是打印在固定位置中断的原因。 (根据 http://www.vim.org/htmldoc/various.html#printing< /a> 看起来你不能让 vim 在打印过程中尊重换行/换行。)
为了避免这种情况,如果你希望文本在编辑时换行,请
在第 70 列处换行。 如果你希望你的文件有长行(例如,这样当加载到 MS Word 或其他东西时它的格式很好),那么你必须在打印之前对文本版本进行预处理。 因此,例如,您可以尝试:
或者如果您安装了 enscript,您应该能够尝试:
打印。 可以通过在 vim 中运行来包装现有文件:
即,'gg' 转到文件开头,'gqG' 重新格式化 'gq' 从当前位置(即第一行)到最后一行(通过转到'G')。 “gq”将尊重您当前的文本宽度设置。
You are creating a text file without any built-in linebreaks so each paragraph is a single "line", even though with linebreak and wrap set, it looks like they are multiple lines). This is why printing breaks at fixed places. (According to http://www.vim.org/htmldoc/various.html#printing it does not seem like you can have vim respect linebreak/wrap during print.)
To avoid this, if you want text to wrap while you are editing, do
to wrap at the 70th column. If you want your file to have long lines (e.g., so it formats fine when loaded into MS Word or something), then you will have to pre-process the text version before printing it. So, for example, you can try:
or if you have enscript installed, you should be able to try:
to print. An existing file can be wrapped by running in vim:
that is, 'gg' to go to start of file and 'gqG' to reformat 'gq' from the current position (i.e. the first line) to the last line (by going to 'G'). 'gq' will respect your current textwidth setting.