简体   繁体   中英

HTML shows different DOCTYPE when opening with VIM

I have an HTML file with HTML 5 DOCTYPE. When I open it with TextEdit or any other Mac tools, it shows correctly with HTML 5. However, when I open it using VIM through Terminal, the HTML file shows up completely different, with HTML 4 DOCTYPE.

Original HTML 5 code:

<!DOCTYPE html>
<html class="test" lang="bg">


<head>
    <meta charset="utf-8">
    <meta content="initial-scale=1, minimum-scale=1, width=device-width" name="viewport">

Weird code when opening with VIM:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta http-equiv="Content-Style-Type" content="text/css">
  <title></title>
  <meta name="Generator" content="Cocoa HTML Writer">
  <meta name="CocoaVersion" content="2113.4">
  <style type="text/css">
    p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo; color: #440003; -webkit-text-stroke: #440003; background-color: #ffffff}
    p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo; color: #440003; -webkit-text-stroke: #440003}
    span.s1 {font-kerning: none}
    span.Apple-tab-span {white-space:pre}
  </style>
</head>

I can hardly believe they are the same file what here they are. What is the reason that made this change happen and what should I do to keep it as the original code everywhere?

您看到添加的行来自使用 TextEdit 作为 html 文件的编辑器,通过简短的谷歌搜索,您可以找到有关它的信息。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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