Ubuntu system to install sublime and set Chinese Input tutorial, ubuntusublime
I. How to install sublime text 3 in ubuntu 16.04
1) first download the tar package of sublime text 3
$ wget
2) decompress the downloaded installation package
$ tar xvf sublime_text_3_build_3114_x64.tar.bz2
3) cd enter the sublime text 3 folder and run./sublime_text to open sublime text 3
Although sublime text 3 has been installed, Chinese input is not supported in sublime text 3 at this time. Let's configure the support for Chinese Input Methods in sublime text 3.
Ii. sublime text 3 Chinese input configuration problems
1) First, ensure that the sogou input method has been installed in the system. If the sogou input method is installed in linux, use Baidu to solve the problem.
2) Save the following code to the file sublime_imfix.c (located in ~ Directory)
#include
void gtk_im_context_set_client_window (GtkIMContext *context, GdkWindow *window) { GtkIMContextClass *klass; g_return_if_fail (GTK_IS_IM_CONTEXT (context)); klass = GTK_IM_CONTEXT_GET_CLASS (context); if (klass->set_client_window) klass->set_client_window (context, window); g_object_set_data(G_OBJECT(context),"window",window); if(!GDK_IS_WINDOW (window)) return; int width = gdk_window_get_width(window); int height = gdk_window_get_height(window); if(width != 0 && height !=0) gtk_im_context_focus_in(context); }
3) Compile the code in the previous step into a shared library libsublime-imfix.so, command
gcc -shared -o libsublime-imfix.so sublime_imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPIC
If the following problems occur:
Enter the following command before compiling
sudo apt-get install libgtk2.0-dev
4) copy the libsublime-imfix.so to the folder where sublime_text is located
Sudomvlibsublime-imfix.so./sublime_text_3/(here based on the path of the folder where sublime text 3 is stored)
5) modify the file/usr/bin/subl content
sudo gedit /usr/bin/subl
Set
#!/bin/shexec /opt/sublime_text/sublime_text "$@"
Change
#!/bin/shLD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text "$@"
Note: If the subl file does not exist, create it by yourself. After the creation, copy and paste the code to be modified and paste it. Then, enter the/usr/bin directory to grant the subl file executable permissions.
sudo chmod +x subl
Finally, execute the command
subl
After the command is executed, sublime text 3 will automatically pop up and support Chinese input!
6) to enable Chinese input when right-clicking a file, you also need to modify the content of the file sublime_text.desktop In the sublime text 3 directory.
sudo gedit ~/sublime_text_3/sublime_text.desktop
Replace the string in [Desktop Entry]
Exec=/opt/sublime_text/sublime_text %F
Change
Exec=bash -c "LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text %F"
Set the string in [Desktop Action Window]
Exec=/opt/sublime_text/sublime_text -n
Change
Exec=bash -c "LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text -n"
Set the string in [Desktop Action Document]
Exec=/opt/sublime_text/sublime_text --command new_file
Change
Exec=bash -c "LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text --command new_file"
Now, the installation and configuration of sublime text 3 under ubuntu 16.04 are complete!