vim – 重新加载缓冲区中的所有文件后文件类型设置丢失

跑完后:bufdo e!
我的所有文件都丢失了文件类型设置,我必须手动运行:在每个文件中设置ft = XXX.

有谁知道如何解决这个问题?

运行:bufdo set ft = XXX不起作用,我不想以任何速率将所有文件设置为相同的文件类型.

干杯.

您可以通过以下autocmd自动修复此问题:
" Enable Syntax highlighting when buffers were loaded through :bufdo,which
" disables the Syntax autocmd event to speed up processing.
augroup EnableSyntaxHighlighting
    " Filetype processing does happen,so we can detect a buffer initially
    " loaded during :bufdo through a set filetype,but missing b:current_Syntax.
    " Also don't do this when the user explicitly turned off Syntax highlighting
    " via :Syntax off.
    " Note: Must allow nesting of autocmds so that the :Syntax enable triggers
    " the ColorScheme event. Otherwise,some highlighting groups may not be
    " restored properly.
    autocmd! BufWinEnter * nested if exists('Syntax_on') && ! exists('b:current_Syntax') && ! empty(&l:filetype) | Syntax enable | endif

    " The above does not handle reloading via :bufdo edit!,because the
    " b:current_Syntax variable is not cleared by that. During the :bufdo," 'eventignore' contains "Syntax",so this can be used to detect this
    " situation when the file is re-read into the buffer. Due to the
    " 'eventignore',an immediate :Syntax enable is ignored,but by clearing
    " b:current_Syntax,the above handler will do this when the reloaded buffer
    " is displayed in a window again.
    autocmd! BufRead * if exists('Syntax_on') && exists('b:current_Syntax') && ! empty(&l:filetype) && index(split(&eventignore,','),'Syntax') != -1 | unlet! b:current_Syntax | endif
augroup END

编辑:添加autocmd嵌套以正确恢复突出显示组并处理缓冲区重新加载,因为明确要求此问题.

相关文章

普通模式 >G 增加当前行到文档末尾处的缩紧层级 $ 移动到本行的末尾 . 相当于一个...
原文连接: https://spacevim.org/cn/layers/lang/elixir/ 模块简介 功能特性 启用模块 快捷键 语言专属...
原文连接: https://spacevim.org/cn/layers/lang/dart/ 模块简介 功能特性 依赖安装及启用模块 启用模...
 =   赋值操作符,可以用于算术和字符串赋值 +        加法计算     -        减法运算...
1.根据包名来查看指定的APP指定数据 adb shell "top | grep com.xxx.xxx" 由于这样打印出来的数...
ctrl+F 向下翻页 ctrl+B 向下翻页 u 取消最近一次操作 U 取消当前行的操作 ZZ 保存当前内容并退出 gg 跳...