Ubuntu 14.04 installs sublime Text 3 and uses the Sublimeclang plugin

Source: Internet
Author: User
Tags sublime text using git



Reprint please indicate source: http://blog.csdn.net/cywosp/article/details/32721011



Sublime text is a cross-platform editor, support Windows, Linux, Mac system platform, support the code editing of various languages, with the corresponding plug-in, the point of time to learn, you will love it, greatly improve your coding efficiency. This article will explain the installation of Sublimetext 3 in the Ubuntu 14.04 system and configure the Sublimeclang plugin to configure the C/D + + development environment.
1. Download and install Sublime Text 3
On the official website HTTP://WWW.SUBLIMETEXT.COM/3 Download the 64-bit (System bit 64-bit). Deb installation package (Http://c758482.r82.cf2.rackcdn.com/sublime-text_ BUILD-3059_AMD64.DEB), after downloading, double-click Install. Once installed, the program can be opened with the command Subl, which is already ready to write code. Before you begin, it is recommended that you write down some common shortcut keys, for reference: http://blog.csdn.net/cywosp/article/details/31791881



Or, install using the command line:



(1) Add sublime Text 3 warehouse:


sudo add-apt-repository ppa:webupd8team/sublime-text-3


press ENTER to continue and establish the Trust warehouse.



(2) Update the SOFTWARE library:


Sudo


(3) Install sublime text 3:


sudo Install Sublime-text-installer


2. Install the package Control


The package control is a good tool for managing plug-ins that can be used to install, delete, and disable the appropriate plugins, which can be found on top of common plugins. Its source address on the Https://github.com/wbond/package_control_channel, installation is very convenient, using Git to clone the code first, and then copied to the ~/.config/sublime-text-3/ Under the packages/directory and named Package control. (You can also pack and download it directly on GitHub, and then unzip it to the ~/.config/sublime-text-3/packages/directory and name it as the package Control).
CD ~/.config/sublime-text-3/packages/git clone https://Github.com/wbond/package_ Control_channel.git package\ Control

or open Sublime_text and press the shortcut key CTRL + ' (ESC below the key), enter the following information in the Command Input window:

ImportUrllib.request,os,hashlib; h ='2915d1851351e5ee549c20394736b442'+'8bc59f460fa1548d1514676163dafc88'; PF ='Package Control.sublime-package'; IPP = Sublime.installed_packages_path (); Urllib.request.install_opener (Urllib.request.build_opener (Urllib.request.ProxyHandler ())); by = Urllib.request.urlopen ('http://packagecontrol.io/'+ Pf.replace (' ','%20'). read (); DH = hashlib.sha256 (by). Hexdigest ();Print('Error validating download (got%s instead of%s), please try manual install'% (DH, h))ifDH! = hElseOpen (Os.path.join (IPP, PF),'WB'). Write (by)

Restart Sublimetext 3, then use the shortcut key CTRL + Shift + p to enter the package control in the pop-up input box to see the option to install the package. Select it after a while (see the bottom left corner of the state) will pop up the plugin Query and Installation window, enter the plug-in you want to use, select Enter. If it is recommended to install C + + Snipptes,converttoutf8,sublimeastyleformatter plug-in for the C + + development, it is clear what the meaning of Baidu is.


3. Install the powerful Sublimeclang plugin
   Sublimeclang is the only sublime text in the C/s + + auto-complete plug-in, powerful, self-contained grammar check function, but recently the author has stopped updating, currently only in the sublime text 2 of the package Control can be found and installed automatically, in Sublimetext 3 can only be manually installed through the source code in the Https://github.com/quarnster/SublimeClang. The specific installation steps are as follows:


#Install related software
sudo apt-get install cmake build-essential clang git
cd ~ / .config / sublime-text-3 / Packages
git clone --recursive https://github.com/quarnster/SublimeClang SublimeClang
cd SublimeClang
cp /usr/lib/x86_64-linux-gnu/libclang-3.4.so.1 internals / libclang.so #This step is very important. If your clang library is not version 3.4, please copy the corresponding version of the library to internals
cd src
mkdir build
cd build
cmake .. #note the next two points
make


If everything succeeds, the libcache.so library file will be generated in the Sublimeclang/internals directory. Restart Sublime Text, then press the shortcut key CTRL + ' (ESC below the key) to open the control output, see if there is an error, if there is no error, it is OK. The next step is to configure your own files, press CTRL + SHIFT + P shortcut, enter Sublimeclang settings in the pop-up input box, and select the line with user, enter the following information in the Open file:


 
 
{
    "show_output_panel": false,
    "dont_prepend_clang_includes": true,
    "inhibit_sublime_completions": false,

    "options":
    [
        "-std=gnu++11",
        "-isystem", "/usr/include",
        "-isystem", "/usr/include/c++/*",
        "-isystem", "/usr/include/c++/4.8",
        "-isystem", "/usr/include/c++/4.8/*",
        "-isystem", "/usr/include/boost",
        "-isystem", "/usr/include/boost/**",
        "-isystem", "/usr/lib/gcc/x86_64-linux-gnu/4.8/include",
        "-isystem", "/usr/lib/gcc/x86_64-linux-gnu/4.8/include/*"
    ]
}


Note: My gcc version is 4.8, if you are not please replace the corresponding version, in # # # corresponding header file after saving the current file, in the next operation will be more prompt to include in the header file functions or variables.



4. Project examples
From the menu bar, project, ADD Folder to project ... Add the original code directory you already have to sublime text, and then Save Project as ... through project. To save your project so that you can create the project. For example, my machine has a C + + project in/media/wine/workstation/swift, where the code is placed under Swift's swift/base and swift/disruptor two directories, Now you want to make the contents of these two directories automatically prompt when writing code, you need the corresponding configuration changes. Project, Edit project, in the configuration file that you opened, I changed the following:


 
{ "folders":
    [
        { "follow_symlinks": true, "path": "/media/WinE/WorkStation/Swift" }
    ], "settings":
    { "sublimeclang_options":
        [ "-I/media/WinE/WorkStation/Swift", "-I/media/WinE/WorkStation/Swift/swift/base", "-I/media/WinE/WorkStation/Swift/swift/disruptor",
       ]
    }
}


combined above, if you have any questions, please can ask, everyone progress together, hope you can fall in love with a guy.



5. Start sublime in any directory on the terminal



For example, the Sublime_text executable file is installed in the/opt/sublime_text directory



(1) Adding environment variables


sudo gedit/etc/environment


At the end of the environment file path variable (double quotation marks) add ":/opt/sublime_text" (the contents of double quotation marks, note that the path is separated by a colon), save the login again, you can use the command


Echo $PATH


look at the path variable, if there is a route that was added successfully to the description. At this point, open any terminal directly input SUBL can open sublime for editing.






Ubuntu 14.04 installs sublime Text 3 and uses the Sublimeclang plugin


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.