Linux下Sublime Text支持中文输入
sublime Text是一款非常好用的代码文本编辑器,在我的其它文章中有过介绍它的安装,使用后发现在linux下Sublime text下中文输入法失效,不能输入中文,本文就讲解一下如何解决。
平台
- Ubuntu 15.10
- sublime text 3
- fcitx输入法
操作
# 获取Github文件
git clone https://github.com/smslit/SublimeText-IM-Fix.git && cd SublimeText-IM-Fix
# 拷贝修复共享库
sudo cp lib/libsublime-imfix.so /opt/sublime_text
# 拷贝软件链接
sudo cp bin/subl /usr/bin
# 拷贝启动器快捷方式
sudo cp applications/sublime_text.desktop /usr/share/applications/
命令行:subl或者Launcher启动运行软件,如果顺利的话应该支持中文输入了。
详解
其实安装完Sublime text后,会在**/usr/bin/**下生成subl文件,在**/usr/share/applications/**下生成sublime_text.desktop,为了使sublime text支持中文输入,在启动软件的时候需要调用**libsublime-imfix.so**,在上述操作中拷贝的文件就是修改之后的subl和sublime_text.desktop。下面主要说明一下修改的地方。
subl文件
原文件内容:
#!/bin/sh
exec /opt/sublime_text/sublime_text "$@"
修改后的文件内容:
#!/bin/sh
LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text "$@"
对比可发现,是在原来的语句前加了调用修复库libsublime-imfix.so的语句
LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so
sublime_text.desktop文件
修改的地方有三点,均在Exec的位置,也是在运行软件的语句前加了调用修复库libsublime-imfix.so的语句。
原文件:
[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;
修改后的文件:
[Desktop Entry]
Version=1.0
Type=Application
Name=Sublime Text
GenericName=Text Editor
Comment=Sophisticated text editor for code, markup and prose
Exec=bash -c "LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so 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=bash -c "LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text -n"
OnlyShowIn=Unity;
[Desktop Action Document]
Name=New File
Exec=bash -c "LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text --command new_file"
OnlyShowIn=Unity;