gpt4 book ai didi

vim - 在 VIM 中,如何将一行很长的行分成多行?

转载 作者:行者123 更新时间:2023-12-03 04:18:17 26 4
gpt4 key购买 nike

假设我在 VIM 编辑器中有一个超长的行(大约 300 多个字符)。我如何将其分成多行,以便单词边界大致在 80 个字符处断开?

示例:

This is a really long line This is a really long line This is a really long line This is a really long line This is a really long line This is a really long line This is a really long line This is a really long line This is a really long line This is a really long line This is a really long line

This is a really long line 
This is a really long line
This is a really long line
This is a really long line
This is a really long line
This is a ...

最佳答案

Vim 做到这一点非常简单(在单词边界处换行)。

gq{motion} % format the line that {motion} moves over
{Visual}gq % format the visually selected area
gqq % format the current line
...

我建议您查看 :help gq:help gw

此外,设置文本宽度 (tw) 将使您在输入过程中超出时自动换行。它也用于 gq 中,但如果禁用 gq 则会破坏窗口大小或 79,具体取决于哪个先出现。

:set tw=80

通过设置格式选项以包含文本宽度,vim 将自动在 tw 设置处中断。

:set fo+=t

关于vim - 在 VIM 中,如何将一行很长的行分成多行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1272173/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com