vim - "vim:filetype"在 vscode 中等效

标签 vim visual-studio-code syntax-highlighting file-type file-type-associations

Vim 有一个很好的方法来指示特定文件应该使用什么语法高亮显示(通过在文件的开头或结尾指定关键字 vim:filetype 来忽略文件扩展名。 )

是否有一种等效的方法可以建议 vscode 对文件使用语法高亮显示而不注意其文件扩展名?

例子:在 vim 中

# vim:filetype=i3
set $mod Mod4
set $alt Mod1
...

I am not looking for files.associations or the Change Language Mode settings. I want to state the language mapping within the file itself and I understand that probably this is not a builtin feature just hoping an extension can do this

Why I am interested in this? because many of the so-called dotfiles in Linux don't have any special extension and when you open the file in another vscode instance (in another machine) you want the IDE to be intelligent enough to deduce the correct syntax highlighter.

最佳答案

我知道这个问题已经存在很长一段时间了,但我想我应该分享一下,现在可以通过第三方扩展来解决这个问题: https://marketplace.visualstudio.com/items?itemName=chrislajoie.vscode-modelines

我自己还没有测试过它,但它有很多安装而且绝对没有坏消息,所以它应该可以正常工作。

repo :https://github.com/ctlajoie/vscode-modelines

关于vim - "vim:filetype"在 vscode 中等效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59547975/

相关文章:

vim:每次缓冲区更改时运行一些代码

vim - 在节点 Docker 镜像中安装 vim

c - VScode : Disable syntax highlighting for a range of lines

php - 查询字符串的 Javascript 或 PHP 语法突出显示?

vim - 将 unicode 代码点转换为字符的表达式

vim - 在 Vim 中自定义语法高亮

visual-studio-code - 如何在 vscode 中禁用受限模式功能和/或横幅

node.js - 使用 javascript/typescript 在 vscode 中预览转换

javascript - Visual Studio 2010-智能感知和 JavaScript 中的突出显示不起作用

visual-studio - 在 Visual Studio 2008 中突出显示选择的关键字