vim 无法将 Podfile 和 podspec 文件识别为 Ruby 文件

问题描述 投票:0回答:2

如何让vim将Podfile和podspec文件(一些没有扩展名的文件)识别为ruby文件,以便vim进行语法高亮。

ruby vim vim-syntax-highlighting podfile
2个回答
2
投票

将其添加到您的 .vimrc

autocmd BufNewFile,BufRead Podfile,*.podspec set filetype=ruby

此行指示 Vim 将 Podfiles 和带有 .podspec 扩展名的文件视为 Ruby 文件,以便它们继承 Ruby 语法突出显示。


0
投票

对于 NeoVim / Lua:

local auto_command_on = vim.api.nvim_create_autocmd

auto_command_on({ "BufRead", "BufNewFile" }, {
  pattern = { "*.podspec", "Podfile" },
  command = "set filetype=ruby",
})

当您打开/创建“.podspec”或“Podfile”时,neovim 将该文件视为 ruby 文件

基于 Cy Rossignol 的回答。

© www.soinside.com 2019 - 2024. All rights reserved.