在 nautilus 中为特定文件类型设置默认应用程序

Mar*_*rco 9 defaults nautilus

我使用 nautilus 作为文件管理器,并希望使用 Vim 而不是 Gedit 来编辑我的文本文件。许多文件(日志文件、空文件……)已经用 Vim 打开,但不是所有文件,例如 tex 文件和 XML 文件仍然用 Gedit 打开。

update-alternatives --get-selections | grep edit 产量

editor                auto     /usr/bin/vim.gnome
gnome-text-editor     manual   /usr/bin/vim.gnome
readline-editor       auto     /usr/bin/rlwrap
Run Code Online (Sandbox Code Playgroud)

并且我还设置了VISUALEDITOR环境变量以指向 vim。

尽管问题是关于更改任何文件类型的默认应用程序,但可以使用仅解决上述更改默认编辑器问题的解决方案来回应,因为这是目前困扰我的问题。

编辑:

“hesse”的答案适用于大多数文件类型,但不适用于所有文件类型。例如 Makefiles 仍然用 Gedit 打开。file --mime-type Makefile返回text/plain,它已包含在~/.local/share/applications/defaults.list. 然而file --mime-type somefile也返回text/plain但是是用 Vim 打开的。

我使用 Debian 不稳定。

小智 10

关键是文件|属性。选择此菜单项并选择目标文件类型的文件,转到“打开方式”选项卡,然后按“重置”。然后选择一个应用程序并按“设为默认值”。在 Nautilus 3.2.1 上测试的厨房。


小智 5

你应该看看~/.local/share/applications/defaults.list下面[Default Applications]。在那里,您应该将text/plainto设置为指向.desktopfor的条目vim,该条目通常位于/usr/share/applications/. 例如:

text/plain=gvim.desktop
Run Code Online (Sandbox Code Playgroud)