gpt4 book ai didi

macos - 如何更改所有类型的基于文本的文件的默认文本编辑器,无论扩展名是什么?

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

我知道 Finder 具有更改默认应用程序的内置选项,但这仅适用于该扩展程序。我想为所有类型的文本文件提供我的编辑器 (MacVim)。例如 .html、.xml、... .gitignore 等,甚至是未知的扩展名like.this

我试过了duti但看起来不再工作了。

我也试过:

$ defaults write com.apple.LaunchServices LSHandlers -array-add '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=org.vim.MacVim;}'
$ defaults read com.apple.LaunchServices
{
LSHandlers = (
{
LSHandlerContentType = "public.plain-text";
LSHandlerRoleAll = "org.vim.MacVim";
}
);
}

以及不同的 UTI,例如 public.textpublic.utf8-plain-text。运气不好。

感谢任何帮助。我不想再看到 TextEdit...

最佳答案

嗯,this answer在 Ask Different 上提到你的方法已经过时了。它还指向 another answer这应该适用于较新的 macOS 版本(Mavericks 之后的版本)。

默认写入 com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add\
'{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=org.vim.MacVim;}'

请注意代码中的 com.apple.LaunchServices LSHandlers -array-addcom.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add< 之间的区别 在提供的解决方案中。

编辑

我忘了提到需要重新启动(尽管链接的答案确实提到了这一点)。

此外,请注意(请参阅此答案的评论)OP 显然需要使用 defaults read com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers > defualts.txt 导出所有默认值,通过文本编辑器将所有应用程序更改为 org.vim.MacVim,然后通过 defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers "$ 重新导入它们(cat defualts.txt)”

关于macos - 如何更改所有类型的基于文本的文件的默认文本编辑器,无论扩展名是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43011299/

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