问题描述
限时送ChatGPT账号..这感觉像是一个愚蠢的问题,但我在互联网上(或在 VIM 帮助中)找不到答案.我在 Mac OS X 上使用 VIM 7.2.我想做的就是用 72 个字符换行,但是做
This feels like a dumb question, but I can't find an answer on the Internet (or in VIM help). I'm using VIM 7.2 on Mac OS X. All I want to do is wrap my lines at 72 characters, but doing
:set textwidth=72
没有效果.textwidth 设置正确(我可以在查询:set textwidth"时看到这一点),但是在设置 textwidth 后我输入的现有行和新行都没有被换行.如果我开始一个新行,仍然不会换行.打开和关闭文件,没有变化.我也试过 :set wrapmargin=72 (with textwidth=0),没有效果.
has no effect. The textwidth is being set correctly (I can see that when I just query ":set textwidth"), but neither existing lines nor new lines that I type after setting textwidth get wrapped. If I start a new line, still doesn't wrap. Open and close the file, no change. I've also tried :set wrapmargin=72 (with textwidth=0), with no effect.
我在这里遗漏了什么?
推荐答案
尝试 gggqG
将新的文本宽度应用到整个缓冲区.
Try gggqG
to apply the new text width to the whole buffer.
gg
表示:到缓冲区的开头 gq
表示:重新格式化包含在动作中的文本G
表示:到缓冲区的末尾
gg
means : go to the beginning of buffer
gq
means : reformat the text included in the motion
G
means : go to the end of the buffer
(如果格式选项设置正确,它将起作用,如 Zyx 帖子中所述)
(It will works if the format options are correctly set, as detailed in Zyx post)
另一方面,您还可以通过在文件的开头或结尾添加 modeline
来显示宽度为 72 个字符的现有文本.见:help modeline
On the other hand, you could also display your existing text with a width of 72 characters by adding a modeline
at the beginning or end of your file. See :help modeline
像 vim:tw=72
这样的东西应该可以工作.
Something like vim:tw=72
should work.
这篇关于vim textwidth 没有效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论