vim textwidth 没有效果

编程入门 行业动态 更新时间:2024-10-15 14:14:13
本文介绍了vim textwidth 没有效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送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 gggqGto 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:关键词]

本文发布于:2023-04-30 20:28:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1399431.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:效果   vim   textwidth

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!