{"id":1513,"date":"2012-08-07T11:35:22","date_gmt":"2012-08-07T03:35:22","guid":{"rendered":"http:\/\/doophp.sinaapp.com\/?p=1513"},"modified":"2012-08-07T11:37:46","modified_gmt":"2012-08-07T03:37:46","slug":"vim-line-ending","status":"publish","type":"post","link":"https:\/\/blog.vimge.com\/archives\/vim\/vim-line-ending.html","title":{"rendered":"Vim\u6362\u884c\u4e71\u7801(^M)\u5904\u7406"},"content":{"rendered":"

Vim\u6253\u5f00\u6587\u4ef6\u7684\u65f6\u5019\u6709\u65f6\u5019\u4f1a\u51fa\u73b0\u884c\u5c3e\u6709\u591a\u4f59\u7684\u5b57\u7b26\u201c^M\u201d\uff0c\u51fa\u73b0\u8fd9\u4e2a\u7b26\u53f7\u7684\u539f\u56e0\u662f\u6587\u4ef6\u4e2d\u4f7f\u7528\u591a\u79cd\u6362\u884c\u7b26\u6df7\u5408\u4f7f\u7528\u9020\u6210\u7684\u3002<\/p>\n

\"\"<\/a><\/p>\n

\u6362\u884c\u7b26(Line-Ending)\u4e3b\u8981\u6709\u4e09\u79cd, CR, LF, CRLF.<\/p>\n

CR(\\r)\u662fMac\u91c7\u7528\u7684\u65b9\u5f0f,<\/p>\n

LF(\\n)\u662fUNIX\/Linux\u91c7\u7528\u7684\u65b9\u5f0f,<\/p>\n

CRLF(\\r\\n)\u662fDOS\/Windows\u91c7\u7528\u7684\u65b9\u5f0f.<\/p><\/blockquote>\n

Vim\u6253\u5f00\u4e00\u4e2a\u6587\u4ef6\u548c\u5199\u5165\u4e00\u4e2a\u6587\u4ef6\u7684\u65f6\u5019\uff0c\u5b83\u9700\u8981\u77e5\u9053\u5982\u4f55\u628a\u6362\u884c\u7b26\u53f7\u5199\u5165\u5230\u7f13\u51b2\u533a\uff0c\u6240\u4ee5\u5728\u4e00\u4e2abuffer\u4e2d\u4e00\u822c\u53ea\u6709\u4e00\u79cd\u6362\u884c\u7b26\uff0c\u5177\u4f53\u662f\u4ec0\u4e48\u6362\u884c\u7b26\u53f7\uff0c\u53d6\u51b3\u4e8efileformat\u7684\u8bbe\u7f6e\uff0c\u5982\u679c\u6ca1\u6709\u8bbe\u7f6e\u7684\u8bdd\uff0c\u5b83\u53ef\u80fd\u4f1a\u6839\u636efileformats\u8fd9\u4e2a\u8bbe\u7f6e\u6765\u51b3\u5b9a\u6700\u540e\u7684fileformat\u3002<\/p>\n

Vim\u4e2d\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8bbe\u7f6e\u6362\u884c\u7b26\uff1a<\/p>\n

\n
set fileformat=dos<\/code><\/pre>\n<\/blockquote>\n
\u5f53\u51fa\u73b0\u591a\u79cd\u6362\u884c\u7b26\u7684\u65f6\u5019\u6211\u4eec\u53ef\u4ee5\u5168\u80fd\u66ff\u6362\u547d\u4ee4\u7edf\u4e00\u6362\u884c\u7b26<\/code>\r\n:%s\/\\r\\(\\n\\)\/\\r\/g<\/code><\/pre>\n


\n\u53c2\u8003\u8d44\u6599\uff1a<\/strong>
\n
http:\/\/stackoverflow.com\/questions\/799417\/gvim-showing-carriage-return-m-even-when-file-mode-is-explicitly-dos<\/a><\/p>\n

http:\/\/www.fanjun.me\/?p=479<\/a>
\n<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"

Vim\u6253\u5f00\u6587\u4ef6\u7684\u65f6\u5019\u6709\u65f6\u5019\u4f1a\u51fa\u73b0\u884c\u5c3e\u6709\u591a\u4f59\u7684\u5b57\u7b26\u201c^M\u201d\uff0c\u51fa\u73b0\u8fd9\u4e2a\u7b26\u53f7\u7684\u539f\u56e0\u662f\u6587\u4ef6\u4e2d\u4f7f\u7528\u591a\u79cd\u6362\u884c\u7b26\u6df7\u5408\u4f7f\u7528\u9020\u6210 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[20],"tags":[65,78],"_links":{"self":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1513"}],"collection":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/comments?post=1513"}],"version-history":[{"count":5,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1513\/revisions"}],"predecessor-version":[{"id":1519,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1513\/revisions\/1519"}],"wp:attachment":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/media?parent=1513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/categories?post=1513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/tags?post=1513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}