HTML 缩进在编译的 Vim 7.4 中不起作用,有什么想法吗? [英] HTML indenting not working in compiled Vim 7.4, any ideas?
问题描述
为了让 vim
正确缩进 .html
文件,我遵循了 此处.
In trying to get vim
to indent .html
files properly, I followed the examples set out here.
给定以下文件 index.html
:
<html>
<body>
<p>
text
</p>
</body>
</html>
我尝试打开它像这样(忽略我的 .vimrc
以确保它不会产生负面干扰)
I tried opening it like so (ignoring my .vimrc
to make sure it isn't interfering negatively)
vim -u NONE index.html
然后我设置选项以启用自动缩进:
Then I set the options to enable automatic indenting:
:filetype plugin indent on
:set filetype=html # abbrev - :set ft=html
:set smartindent # abbrev - :set si
然后我用 gg=G
缩进了整个文件,结果如下:
And then I indented the entire file with gg=G
, and this is the result:
<html>
<body>
<p>
text
</p>
</body>
</html>
我检查以确保 html.vim
文件存在,它肯定存在
I checked to make sure that the html.vim
file existed, and it's definitely there
$ head -2 ~/.vim/after/ftplugin/html.vim
" Vim syntax file
" Language: HTML
$ head -2 ~/.vim/ftplugin/html.vim
" Vim syntax file
" Language: HTML
我的vim版本是7.4:
My version of vim is 7.4:
$ vim --version | head -1
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Sep 23 2013 16:12:20)
它包括智能缩进:
$ vim --version | grep smartindent
-ebcdic +mouse +smartindent +xim
我不知道为什么缩进不起作用!有什么线索或想法可以进一步研究这个问题吗?
I'm at a loss as to why the indentation isn't working! Any clues or ideas to research this problem further?
FWIW,我运行的是 Ubuntu 13.04.
FWIW, I'm running Ubuntu 13.04.
推荐答案
正如 Cory 的回答中提到的,目前分发的版本是 Vimscript 2075.如果您转到该插件页面,您可以看到记录了所有默认情况下会增加缩进的标签.
As mentioned in Cory's answer, the currently distributed version is Vimscript 2075. If you go to that plugin page you can see documented all the tags that by default will increase indent.
您在示例中提供的标签均未包含在此默认列表中,但有很多.
None of the tags you gave in your example are in this default list, but there are plenty of them.
由于 HTML 的缩进对用户的偏好非常开放,因此插件维护者提供了一个选项,可以在增加缩进的标签列表中添加或删除标签.请参阅 :help html-indent,它建议:
Since indentation of HTML is very open to user preference, the plugin maintainer has included an option to add or remove tags to or from the list of tags that increases indent. See :help html-indent, where it suggests:
You can add further tags with:
:let g:html_indent_inctags = "html,body,head,tbody"
这篇关于HTML 缩进在编译的 Vim 7.4 中不起作用,有什么想法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!