HTML编码在编译Vim 7.4中不起作用,有什么想法? [英] HTML indenting not working in compiled Vim 7.4, any ideas?

查看:107
本文介绍了HTML编码在编译Vim 7.4中不起作用,有什么想法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在试图让 vim 正确缩进 .html 文件时,我遵循了在这里



给定以下文件 index.html

 < HTML> 
< body>
< p>
text
< / p>
< / body>
< / html>

我试过打开它像这样(忽略我的 .vimrc 以确保它不会产生负面影响)

  vim -u NONE index.html 

然后,我设置选项启用自动缩进:

 :filetype插件缩进
:set filetype = html#abbrev - :set ft = html
:set smartindent#abbrev - :set si

然后我用 gg = G ,结果如下:

 < html> 
< body>
< p>
text
< / p>
< / body>
< / html>

我检查了 html.vim 文件已存在,并且它肯定存在

  $ head -2〜/ .vim / after / ftplugin / html.vim 
Vim语法文件
语言:HTML
$头文件-2〜/ .vim / ftplugin / html.vim
Vim语法文件
语言:HTML

我的vim版本是7.4:

  $ vim --version | head -1 
VIM-Vi IMproved 7.4(2013年8月10日,编译Sep 23 2013 16:12:20)

它包括智能缩进:

  $ vim --version | grep smartindent 
-ebcdic + mouse + smartindent + xim

为什么缩进不起作用!任何线索或想法,进一步研究这个问题?

FWIW,我正在运行的Ubuntu 13.04。

解决方案

正如Cory的回答中所提到的,目前分发的版本是 Vimscript 2075 <一>。如果您进入该插件页面,您可以看到所有默认情况下会增加缩进的标签。



您在示例中给出的所有标签都不在此默认列表中,但有很多。



由于HTML的缩进对用户偏好非常开放,因此插件维护人员可以添加或删除标签增加缩进的标签列表。请参阅:help html-indent,它表示:

 您可以添加更多标签:

:let g:html_indent_inctags =html,body,head,tbody


In trying to get vim to indent .html files properly, I followed the examples set out here.

Given the following file index.html:

<html>
  <body>
    <p>
    text
    </p>
  </body>
</html>

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

And then I indented the entire file with gg=G, and this is the result:

<html>
<body>
<p>
text
</p>
</body>
</html>

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

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)

And it includes smart indent:

$ 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, I'm running Ubuntu 13.04.

解决方案

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.

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屋!

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