Vim 格式选项-=或 [英] Vim formatoptions-=or

查看:24
本文介绍了Vim 格式选项-=或的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 vimrc 中有以下几行:

I have the following lines in my vimrc:

" Don't add the comment prefix when I hit enter or o/O on a comment line.
set formatoptions-=or

它曾经在某些时候起作用.我不知道我做了什么,但它不再是了,我在创建换行符时仍然收到评论.什么可以禁用它?这是我的 vimrc:http://pastebin.com/kVWWWeQWW

It used to work at some point. I don't know what I did but it doesn't anymore, I still get comments when creating newlines. What could have disabled it? Here's my vimrc: http://pastebin.com/kVWWeQWW

推荐答案

如果你发现启动后标志 o 被插入回 formatoptions,你应该找到找出为什么会发生这种情况并修复它.这似乎比总是执行 autocmd 更干净,即使在删除选项之后也是如此.

If you found that the flag o is being inserted back in formatoptions after startup, you should find out why this is happening and fix it. This seems cleaner than always executing an autocmd, even after the option is removed.

您可以使用以下命令检查选项的设置位置:

You could check where the option is set issuing with following commands:

:5verbose set fo?
:5verbose setl fo?

<小时>

如果您的问题出在 Vim 目录 ($VIMRUNTIME/ftplugin) 上的 ftplugin 文件上,则不应更改该文件,因为该更改会被撤销当 Vim 更新时.更改它的正确方法是在您的 after 目录中,如 :h after-directory 中所述.

If your problem is with a ftplugin file that lies on Vim directory ($VIMRUNTIME/ftplugin) you shouldn't change that file, because that change would be undone when Vim is updated. The proper way to change it is in your after directory, as explained in :h after-directory.

假设问题发生在 c 文件类型,创建文件 ~/.vim/after/ftplugin/c.vim 包含你的 setlocal formatoptions-= 命令.

Supposing that the problem occurs with c filetype, create file ~/.vim/after/ftplugin/c.vim containing your setlocal formatoptions-= commands.

这篇关于Vim 格式选项-=或的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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