Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 如何更改所有类型的基于文本的文件的默认文本编辑器,无论扩展名是什么?_Macos_Macos Sierra - Fatal编程技术网

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

Macos 如何更改所有类型的基于文本的文件的默认文本编辑器,无论扩展名是什么?,macos,macos-sierra,Macos,Macos Sierra,我知道Finder内置了更改默认应用程序的选项,但这仅适用于该扩展。我想为所有类型的文本文件提供我的编辑器(MacVim)。例如.html、.xml等。gitignore等,甚至像这样的未知扩展 我已经试过了,但看起来好像不再工作了 我还尝试: $ defaults write com.apple.LaunchServices LSHandlers -array-add '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=org.v

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

我已经试过了,但看起来好像不再工作了

我还尝试:

$ 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.text
public.utf8纯文本
。不走运

谢谢你的帮助。我不想再看到文本编辑了…

好吧,在询问不同的人时,你的方法已经过时了。它还指出,新的macOS版本(那些在Mavericks之后出现的版本)应该可以使用

defaults写入com.apple.LaunchServices/com.apple.LaunchServices.secure LSHandlers-数组添加\
“{LSHandlerContentType=public.plain text;LSHandlerRoleAll=org.vim.MacVim;}”

请注意代码中的
com.apple.LaunchServices LSHandlers-数组添加
与提供的解决方案中的
com.apple.LaunchServices/com.apple.LaunchServices.secure LSHandlers-数组添加
之间的区别

编辑

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


另外,请注意(参见此答案的评论),OP显然需要导出所有默认值,默认值为com.apple.LaunchServices/com.apple.LaunchServices.secure LSHandlers>defualts.txt,通过文本编辑器将所有应用程序更改为
org.vim.MacVim
,在通过
默认值重新导入之前,请编写com.apple.LaunchServices/com.apple.LaunchServices.secure LSHandlers“$(cat defaults.txt)”

谢谢,但不起作用。我甚至用
默认值导出了全部默认值,读取com.apple.LaunchServices/com.apple.LaunchServices.secure LSHandlers>defaults.txt
,用我的编辑器用org.vim.MacVim更改了所有应用程序,然后输入
默认值write com.apple.LaunchServices/com.apple.LaunchServices.secure LSHandlers“$(cat defaults.txt)”
。仍然不工作,并打开TextEdit。我不知道为什么我真的需要重新开始。。。现在可以了,谢谢。我会接受这个答案,但如果有人想全部改变,需要使用我的方法。