加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

vim – 如果不在行的末尾插入,则限制文本宽度不能按预期工作

发布时间:2020-12-15 21:33:10 所属栏目:安全 来源:网络整理
导读:我知道我们可以使用:set tw = 80来限制文本宽度.但是,如果我们在结束之前插入文本,则此函数根本不起作用. 例如,假设我们输入“您希望通过电子邮件向您发送问题的回复吗?” 如果我们继续在“?”之后输入,则tw工作正常.但是如果我们在说“have”之前插入它,
我知道我们可以使用:set tw = 80来限制文本宽度.但是,如果我们在结束之前插入文本,则此函数根本不起作用.

例如,假设我们输入“您希望通过电子邮件向您发送问题的回复吗?”

如果我们继续在“?”之后输入,则tw工作正常.但是如果我们在说“have”之前插入它,即使它超过指定的文本宽度也不会中断.

有没有办法在后一种情况下使这项工作?

解决方法

这可能是使用 formatoptionsformatexpr配置的,但我不知道如何.
另一种解决方案是在视线选择上使用gq手动格式化,即如果文本宽度> = tw则添加断裂线.

>在另一个文本块中键入您喜欢的任何文本,从而使其宽度为80个字符或更多
>使用V(Shiftv)选择您认为格式错误的文本
> gq

:h gq

Format the lines that {motion} moves over.
Formatting is done with one of three methods:
1. If 'formatexpr' is not empty the expression is
   evaluated.  This can differ for each buffer.
2. If 'formatprg' is not empty an external program
   is used.
3. Otherwise formatting is done internally.

In the third case the 'textwidth' option controls the
length of each formatted line (see below).
If the 'textwidth' option is 0,the formatted line
length is the screen width (with a maximum width of
79).
The 'formatoptions' option controls the type of
formatting fo-table.
[..]

有关Vim文本宽度如何工作的更多信息,请查看
How to use Vim’s textwidth like a pro

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读