Vim:`set formatoptions` 丢失了吗? [英] Vim: `set formatoptions` being lost?

查看:25
本文介绍了Vim:`set formatoptions` 丢失了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 vimrc 中有 set formatoptions=cqn,但由于某种原因它不坚持.Vim 似乎在某个时候恢复到默认值 (fo=tcq)……但我不知道为什么.运行 -V100/tmp/log 只会给我:

formatoptions=tcq最后一组来自 ~/.vimrc

没有有用的上下文.

那么,有没有办法让 formatoptions 坚持下去?或者我是否只需要创建一个 autocmd 来在每次加载新文件时重置它?

编辑

使用 :verbose set formatoptions 显示:

<前>格式选项=tcq最后一组来自 ~/.vimrc

然而,在我的 ~/.vimrc 中对 foformatoptions 的唯一引用是 set formatoptions+=cqn.

解决方案

根据 formatoptions 上的 vim 文档:

<块引用>

注意:此选项设置为 Vi'compatible' 时的默认值是
设置并为 Vim 默认值,当兼容"已重置.

因此,如果 compatible 的值在此过程中不断变化,则可能会导致您看到的问题.

I've got set formatoptions=cqn in my vimrc, but for some reason it doesn't stick. It seems like Vim is reverting to the default (fo=tcq) at some point… But I can't figure out why. Running -V100/tmp/log just gives me:

formatoptions=tcq
  Last set from ~/.vimrc

With no useful context.

So, is there any way to make formatoptions stick? Or do I just need to create an autocmd to reset it each time a new file is loaded?

Edit

Using :verbose set formatoptions shows this:

formatoptions=tcq
  Last set from ~/.vimrc

However, the only reference to fo or formatoptions in my ~/.vimrc is set formatoptions+=cqn.

解决方案

According to the vim documentation on formatoptions:

NOTE: This option is set to the Vi default value when 'compatible' is
set and to the Vim default value when 'compatible' is reset.

So if the value of compatible is changing along the way, that could be causing the issue you're seeing.

这篇关于Vim:`set formatoptions` 丢失了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆