gpt4 book ai didi

vim - 为什么 `filetype on` 在 vi​​m 中没有检测到文件类型?

转载 作者:行者123 更新时间:2023-12-02 22:40:27 24 4
gpt4 key购买 nike

我打开了 vim 而没有加载任何东西:

vim -V -u NONE

然后输入一行:

<?xml?>

运行后:

:unlet did_load_filetypes
:filetype on

我检查当前缓冲区的文件类型:

:set ft?

它打印filetype=


如果我输入

:unlet did_load_filetypes
:filetype detect

然后 :set ft? 将打印 filetype=xml


在 vim 文档中:

Detail: The ":filetype on" command will load one of these files:                                    
Amiga $VIMRUNTIME/filetype.vim
Mac $VIMRUNTIME:filetype.vim
MS-DOS $VIMRUNTIME\filetype.vim
RiscOS Vim:Filetype
Unix $VIMRUNTIME/filetype.vim
VMS $VIMRUNTIME/filetype.vim
This file is a Vim script that defines autocommands for the
BufNewFile and BufRead events. If the file type is not found by the
name, the file $VIMRUNTIME/scripts.vim is used to detect it from the
contents of the file.

:filetype on:filetype detect 有什么区别?
感谢您的帮助。

最佳答案

来自手册:

To detect the file type again:
:filetype detect
Use this if you started with an empty file and typed text that makes it
possible to detect the file type.

关于vim - 为什么 `filetype on` 在 vi​​m 中没有检测到文件类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10844301/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com