如何真正使 Sublime Text Build 3143 成为 Ubuntu 16.04.3 中的默认文本编辑器

如何真正使 Sublime Text Build 3143 成为 Ubuntu 16.04.3 中的默认文本编辑器

你可能会说这是重复的,如果我没有看这里的话

Sublime Text 作为所有文本文件的默认编辑器

和这里

如何将 Sublime Text 3 设为默认文本编辑器

但它并没有解决我的问题。我的笔记本坏了。

以下是我的 /usr/share/applications/sublime_text.desktop 的样子

[Desktop Entry]
Version=1.0
Type=Application
Name=Sublime Text
GenericName=Text Editor
Comment=Sophisticated text editor for code, markup and prose
Exec=/opt/sublime_text/sublime_text %F
Terminal=false
MimeType=text/plain;
Icon=sublime-text
Categories=TextEditor;Development;
StartupNotify=true
Actions=Window;Document;

[Desktop Action Window]
Name=New Window
Exec=/opt/sublime_text/sublime_text -n
OnlyShowIn=Unity;

[Desktop Action Document]
Name=New File
Exec=/opt/sublime_text/sublime_text --command new_file
OnlyShowIn=Unity;

以下是我的 /usr/share/applications/defaults.list 的内容

[Default Applications]
application/csv=libreoffice-calc.desktop
application/excel=libreoffice-calc.desktop
application/msexcel=libreoffice-calc.desktop
application/msword=libreoffice-writer.desktop
application/ogg=rhythmbox.desktop
application/oxps=evince.desktop
application/pdf=evince.desktop
application/postscript=evince.desktop
application/rtf=libreoffice-writer.desktop
application/tab-separated-values=libreoffice-calc.desktop
application/vnd.debian.binary-package=gnome-software-local-file.desktop
application/vnd.ms-cab-compressed=gnome-software-local-file.desktop
application/vnd.lotus-1-2-3=libreoffice-calc.desktop
application/vnd.ms-excel=libreoffice-calc.desktop
application/vnd.ms-word=libreoffice-writer.desktop
application/vnd.ms-xpsdocument=evince.desktop
application/vnd.rn-realmedia=org.gnome.Totem.desktop
application/vnd.sun.xml.base=libreoffice-base.desktop
application/vnd.sun.xml.calc=libreoffice-calc.desktop
application/vnd.sun.xml.calc.template=libreoffice-calc.desktop
application/vnd.sun.xml.draw=libreoffice-draw.desktop
application/vnd.sun.xml.draw.template=libreoffice-draw.desktop
application/vnd.sun.xml.math=libreoffice-math.desktop
application/vnd.sun.xml.writer=libreoffice-writer.desktop
application/vnd.sun.xml.writer.template=libreoffice-writer.desktop
application/vnd.sun.xml.writer.global=libreoffice-writer.desktop
application/vnd.oasis.opendocument.database=libreoffice-base.desktop
application/vnd.oasis.opendocument.formula=libreoffice-math.desktop
application/vnd.oasis.opendocument.graphics=libreoffice-draw.desktop
application/vnd.oasis.opendocument.graphics-template=libreoffice-draw.desktop
application/vnd.oasis.opendocument.presentation=libreoffice-impress.desktop
application/vnd.oasis.opendocument.presentation-template=libreoffice-impress.desktop
application/vnd.oasis.opendocument.spreadsheet=libreoffice-calc.desktop
application/vnd.oasis.opendocument.spreadsheet-template=libreoffice-calc.desktop
application/vnd.oasis.opendocument.text=libreoffice-writer.desktop
application/vnd.oasis.opendocument.text-template=libreoffice-writer.desktop
application/vnd.oasis.opendocument.text-web=libreoffice-writer.desktop
application/vnd.oasis.opendocument.text-master=libreoffice-writer.desktop
application/vnd.sun.xml.impress=libreoffice-impress.desktop
application/vnd.sun.xml.impress.template=libreoffice-impress.desktop
application/vnd.stardivision.calc=libreoffice-calc.desktop
application/vnd.stardivision.draw=libreoffice-draw.desktop
application/vnd.stardivision.impress=libreoffice-impress.desktop
application/vnd.stardivision.math=libreoffice-math.desktop
application/vnd.stardivision.writer=libreoffice-writer.desktop
application/mspowerpoint=libreoffice-impress.desktop
application/vnd.ms-powerpoint=libreoffice-impress.desktop
application/vnd.wordperfect=libreoffice-writer.desktop
application/wordperfect=libreoffice-writer.desktop
application/vnd.openxmlformats-officedocument.wordprocessingml.document=libreoffice-writer.desktop
application/vnd.openxmlformats-officedocument.wordprocessingml.template=libreoffice-writer.desktop
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet=libreoffice-calc.desktop
application/vnd.openxmlformats-officedocument.spreadsheetml.template=libreoffice-calc.desktop
application/vnd.openxmlformats-officedocument.presentationml.slide=libreoffice-impress.desktop
application/vnd.openxmlformats-officedocument.presentationml.slideshow=libreoffice-impress.desktop
application/vnd.openxmlformats-officedocument.presentationml.presentation=libreoffice-impress.desktop
application/vnd.openxmlformats-officedocument.presentationml.template=libreoffice-impress.desktop
application/x-123=libreoffice-calc.desktop
application/x-abiword=abiword.desktop
application/x-applix-spreadsheet=libreoffice-calc.desktop
application/x-ar=org.gnome.FileRoller.desktop
application/x-arj=org.gnome.FileRoller.desktop
application/x-audacity-project=audacity.desktop
application/x-bzdvi=evince.desktop
application/x-bzip-compressed-tar=org.gnome.FileRoller.desktop
application/x-bzip=org.gnome.FileRoller.desktop
application/x-bzpdf=evince.desktop
application/x-bzpostscript=evince.desktop
application/x-cbr=evince.desktop
application/x-cbt=evince.desktop
application/x-cbz=evince.desktop
application/x-compressed-tar=org.gnome.FileRoller.desktop
application/x-compress=org.gnome.FileRoller.desktop
application/x-cab=gnome-software-local-file.desktop
application/x-ms-cab-compressed=gnome-software-local-file.desktop
application/x-deb=gnome-software-local-file.desktop
application/x-debian-package=gnome-software-local-file.desktop
application/x-dos_ms_excel=libreoffice-calc.desktop
application/x-dvi=evince.desktop
application/x-ear=org.gnome.FileRoller.desktop
application/x-excel=libreoffice-calc.desktop
application/x-extension-m4a=org.gnome.Totem.desktop
application/x-extension-mp4=org.gnome.Totem.desktop
application/x-flac=rhythmbox.desktop
application/x-glade=glade.desktop
application/x-gnumeric=gnumeric.desktop
application/x-gtar=org.gnome.FileRoller.desktop
application/x-gzdvi=evince.desktop
application/x-gzip=org.gnome.FileRoller.desktop
application/x-gzpdf=evince.desktop
application/x-gzpostscript=evince.desktop
application/xhtml+xml=firefox.desktop
application/x-jar=openjdk-7-java.desktop
application/x-java-archive=openjdk-7-java.desktop
application/x-java-jnlp-file=icedtea-netx-javaws.desktop
application/x-lha=org.gnome.FileRoller.desktop
application/x-lhz=org.gnome.FileRoller.desktop
application/xls=libreoffice-calc.desktop
application/x-lzop=org.gnome.FileRoller.desktop
application/x-matroska=org.gnome.Totem.desktop
application/x-mps=libreoffice-calc.desktop
application/x-ms-excel=libreoffice-calc.desktop
application/x-msexcel=libreoffice-calc.desktop
application/x-ogg=rhythmbox.desktop
application/x-oleo=libreoffice-calc.desktop
application/x-perl=sublime_text.desktop
application/x-planperfect=libreoffice-calc.desktop
application/x-quattropro=libreoffice-calc.desktop
application/x-rar-compressed=org.gnome.FileRoller.desktop
application/x-rar=org.gnome.FileRoller.desktop
application/x-rpm=org.gnome.FileRoller.desktop
application/x-sc=libreoffice-calc.desktop
application/x-shockwave-flash=org.gnome.Totem.desktop
application/x-sylk=libreoffice-calc.desktop
application/x-tar=org.gnome.FileRoller.desktop
application/x-war=org.gnome.FileRoller.desktop
application/x-xbase=libreoffice-calc.desktop
application/x-xls=libreoffice-calc.desktop
application/x-xzpdf=evince.desktop
application/x-zip-compressed=org.gnome.FileRoller.desktop
application/x-zip=org.gnome.FileRoller.desktop
application/x-zoo=org.gnome.FileRoller.desktop
application/zip=org.gnome.FileRoller.desktop
audio/3gpp=org.gnome.Totem.desktop
audio/ac3=org.gnome.Totem.desktop
audio/AMR=org.gnome.Totem.desktop
audio/AMR-WB=org.gnome.Totem.desktop
audio/basic=org.gnome.Totem.desktop
audio/flac=rhythmbox.desktop
audio/midi=org.gnome.Totem.desktop
audio/mp4=org.gnome.Totem.desktop
audio/mpeg=org.gnome.Totem.desktop
audio/mpegurl=org.gnome.Totem.desktop
audio/ogg=rhythmbox.desktop
audio/prs.sid=org.gnome.Totem.desktop
audio/vnd.rn-realaudio=org.gnome.Totem.desktop
audio/x-ape=org.gnome.Totem.desktop
audio/x-flac=rhythmbox.desktop
audio/x-gsm=org.gnome.Totem.desktop
audio/x-it=org.gnome.Totem.desktop
audio/x-m4a=org.gnome.Totem.desktop
audio/x-matroska=org.gnome.Totem.desktop
audio/x-mod=org.gnome.Totem.desktop
audio/x-mp3=rhythmbox.desktop
audio/x-mpeg=rhythmbox.desktop
audio/x-mpegurl=rhythmbox.desktop
audio/x-ms-asf=org.gnome.Totem.desktop
audio/x-ms-asx=org.gnome.Totem.desktop
audio/x-ms-wax=org.gnome.Totem.desktop
audio/x-ms-wma=org.gnome.Totem.desktop
audio/x-musepack=org.gnome.Totem.desktop
audio/x-pn-aiff=org.gnome.Totem.desktop
audio/x-pn-au=org.gnome.Totem.desktop
audio/x-pn-realaudio=org.gnome.Totem.desktop
audio/x-pn-realaudio-plugin=org.gnome.Totem.desktop
audio/x-pn-wav=org.gnome.Totem.desktop
audio/x-pn-windows-acm=org.gnome.Totem.desktop
audio/x-realaudio=org.gnome.Totem.desktop
audio/x-real-audio=org.gnome.Totem.desktop
audio/x-sbc=org.gnome.Totem.desktop
audio/x-scpls=rhythmbox.desktop
audio/x-speex=org.gnome.Totem.desktop
audio/x-tta=org.gnome.Totem.desktop
audio/x-wav=org.gnome.Totem.desktop
audio/x-wavpack=org.gnome.Totem.desktop
audio/x-vorbis=rhythmbox.desktop
audio/x-vorbis+ogg=rhythmbox.desktop
audio/x-xm=org.gnome.Totem.desktop
image/bmp=eog.desktop
image/gif=eog.desktop
image/jpeg=eog.desktop
image/jpg=eog.desktop
image/pjpeg=eog.desktop
image/png=eog.desktop
image/svg+xml=eog.desktop
image/tiff=eog.desktop
image/vnd.djvu=evince.desktop
image/vnd.rn-realpix=org.gnome.Totem.desktop
image/x-bmp=eog.desktop
image/x-bzeps=evince.desktop
image/x-eps=evince.desktop
image/x-gray=eog.desktop
image/x-gzeps=evince.desktop
image/x-icb=eog.desktop
image/x-ico=eog.desktop
image/x-png=eog.desktop
image/x-portable-anymap=eog.desktop
image/x-portable-bitmap=eog.desktop
image/x-portable-graymap=eog.desktop
image/x-portable-pixmap=eog.desktop
image/x-psd=gimp.desktop
image/x-xbitmap=eog.desktop
image/x-xpixmap=eog.desktop
inode/directory=nautilus-folder-handler.desktop
misc/ultravox=org.gnome.Totem.desktop
multipart/x-zip=org.gnome.FileRoller.desktop
text/abiword=abiword.desktop
text/calendar=evolution.desktop
text/comma-separated-values=libreoffice-calc.desktop
text/csv=libreoffice-calc.desktop
text/plain=sublime_text.desktop
text/richtext=abiword.desktop
text/rtf=libreoffice-writer.desktop
text/spreadsheet=libreoffice-calc.desktop
text/tab-separated-values=libreoffice-calc.desktop
text/x-comma-separated-values=libreoffice-calc.desktop
text/x-c++hdr=ubuntusdk.desktop
text/x-c++src=ubuntusdk.desktop
text/x-xsrc=ubuntusdk.desktop
text/x-chdr=sublime_text.desktop
text/x-csrc=sublime_text.desktop
text/x-dtd=sublime_text.desktop
text/x-java=sublime_text.desktop
text/mathml=sublime_text.desktop
text/x-python=sublime_text.desktop
text/x-sql=sublime_text.desktop
video/3gpp=org.gnome.Totem.desktop
video/dv=org.gnome.Totem.desktop
video/fli=org.gnome.Totem.desktop
video/flv=org.gnome.Totem.desktop
video/mp2t=org.gnome.Totem.desktop
video/mp4=org.gnome.Totem.desktop
video/mp4v-es=org.gnome.Totem.desktop
video/mpeg=org.gnome.Totem.desktop
video/msvideo=org.gnome.Totem.desktop
video/ogg=org.gnome.Totem.desktop
video/quicktime=org.gnome.Totem.desktop
video/vivo=org.gnome.Totem.desktop
video/vnd.divx=org.gnome.Totem.desktop
video/vnd.rn-realvideo=org.gnome.Totem.desktop
video/vnd.vivo=org.gnome.Totem.desktop
video/webm=org.gnome.Totem.desktop
video/x-anim=org.gnome.Totem.desktop
video/x-avi=org.gnome.Totem.desktop
video/x-flc=org.gnome.Totem.desktop
video/x-fli=org.gnome.Totem.desktop
video/x-flic=org.gnome.Totem.desktop
video/x-flv=org.gnome.Totem.desktop
video/x-m4v=org.gnome.Totem.desktop
video/x-matroska=org.gnome.Totem.desktop
video/x-mpeg=org.gnome.Totem.desktop
video/x-ms-asf=org.gnome.Totem.desktop
video/x-ms-asx=org.gnome.Totem.desktop
video/x-msvideo=org.gnome.Totem.desktop
video/x-ms-wm=org.gnome.Totem.desktop
video/x-ms-wmv=org.gnome.Totem.desktop
video/x-ms-wmx=org.gnome.Totem.desktop
video/x-ms-wvx=org.gnome.Totem.desktop
video/x-nsv=org.gnome.Totem.desktop
video/x-ogm+ogg=org.gnome.Totem.desktop
video/x-theora+ogg=org.gnome.Totem.desktop
video/x-totem-stream=org.gnome.Totem.desktop
x-content/video-dvd=org.gnome.Totem.desktop
x-content/video-vcd=org.gnome.Totem.desktop
x-content/video-svcd=org.gnome.Totem.desktop
x-content/audio-cdda=rhythmbox-device.desktop
x-content/audio-dvd=banshee-audiocd.desktop
x-content/audio-player=rhythmbox-device.desktop
x-content/image-dcf=shotwell.desktop
x-content/image-picturecd=shotwell.desktop
zz-application/zz-winassoc-xls=libreoffice-calc.desktop
x-scheme-handler/apt=apturl.desktop
x-scheme-handler/mailto=thunderbird.desktop
x-scheme-handler/snap=org.gnome.Software.desktop
text/html=firefox.desktop;google-chrome.desktop
text/xml=firefox.desktop;google-chrome.desktop
application/xhtml_xml=google-chrome.desktop;
image/webp=google-chrome.desktop;
x-scheme-handler/http=firefox.desktop;google-chrome.desktop
x-scheme-handler/https=firefox.desktop;google-chrome.desktop
x-scheme-handler/ftp=google-chrome.desktop;

但即使看了其中的内容,Sublime 也不是默认的

sudo update-alternatives --config gnome-text-editor

即:

开始

有 2 个替代 gnome-text-editor 的选择(提供 /usr/bin/gnome-text-editor)。

选择路径优先级状态

  • 0 /opt/sublime_text/sublime_text 100 自动模式 1 /opt/sublime_text/sublime_text 100 手动模式 2 /usr/bin/gedit 50 手动模式

按保留当前选择[*],或输入选择编号:

结尾

答案1

要在 Ubuntu 20.04 中设置默认文本编辑器,right click请在 .txt 文件中单击特性,转到打开用,然后选择您喜欢的文本编辑器并点击Set as default

属性菜单屏幕截图

答案2

尝试这个:

sudo rm /etc/alternatives/editor

sudo ln -s /usr/bin/subl /etc/alternatives/editor

相关内容