简体   繁体   English

如何为“utf-8”编码设置vim 7的html整洁选项?

[英]How do I set vim 7's html tidy options for “utf-8” encoding?

I need to run tidy in vim, using the usual: 我需要在vim中运行整洁,使用通常:

:compile tidy

:make

However, if I'm on an utf-8 file, I get errors that I don't see if I run tidy outside of vim, ie, 但是,如果我在utf-8文件上,我会收到错误,如果我在vim之外运行整洁,我就看不到错误,即

tidy -e -q -utf8 <filename>

I get what I'm expecting 我得到了我所期待的

My Vim script skills do not go far enough to have a general solution ready, but what you can do when editing a utf-8 file: 我的Vim脚本技能不够用,无法准备好常规解决方案,但在编辑utf-8文件时可以做些什么:

:compiler tidy
:setlocal makeprg=<TAB> [and edit the tidy command line to include -utf8]
:make

Explanation: 说明:

":compile tidy" just executes the compiler plugin file for tidy and does setlocal to set makeprg to tidy call with some options (-q -e --gnu-emacs yes). “:compile tidy”只是执行编译器插件文件以进行整理,并使用setlocal将makeprg设置为带有一些选项的整齐调用(-q -e -gnu-emacs yes)。 Apparently for utf-8 files tidy needs the additional option -utf8, so you have to set this manually. 显然对于utf-8文件整洁需要额外的选项-utf8,所以你必须手动设置它。 Afterwards you call :make as normal. 然后你打电话:正常。

If you are only editing utf8 files, you can of course edit the tidy compiler plugin file directly and hard code the -utf8 option to tidy there. 如果您只是编辑utf8文件,您当然可以直接编辑整齐的编译器插件文件并硬编码-utf8选项以在那里整理。 Use the following to edit the plugin file 使用以下命令编辑插件文件

:e $VIMRUNTIME/compiler/tidy.vim

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM