我使用 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)
并且我还设置了VISUAL
和EDITOR
环境变量以指向 vim。
尽管问题是关于更改任何文件类型的默认应用程序,但可以使用仅解决上述更改默认编辑器问题的解决方案来回应,因为这是目前困扰我的问题。
编辑:
“hesse”的答案适用于大多数文件类型,但不适用于所有文件类型。例如 Makefiles 仍然用 Gedit 打开。file --mime-type Makefile
返回text/plain
,它已包含在~/.local/share/applications/defaults.list
. 然而file --mime-type somefile
也返回text/plain
但是是用 Vim 打开的。
我使用 Debian 不稳定。
小智 5
你应该看看~/.local/share/applications/defaults.list
下面[Default Applications]
。在那里,您应该将text/plain
to设置为指向.desktop
for的条目vim
,该条目通常位于/usr/share/applications/
. 例如:
text/plain=gvim.desktop
Run Code Online (Sandbox Code Playgroud)