Sublime Text 2 is an amazing editor which I recommend to programmers who enjoy their conventional editor and consider using multiple cursors to be an esoteric act (I admit I used to be one of them). ST2 supports plugins that could transform it into an incredibly productive environment as long as you are willing to remember a few key shortcuts. The languages which I currently use the most are C/C++ so I decided to see if there are any plugins to run syntax analysis and possibly auto-suggest while coding. I found the SublimeClang plugin which uses Clang to analyse the code during writing. Unfortunately, its development was stopped a couple of months ago as the author decided to put it on hold, but promised that it will eventually become part of the completion plugin.

Installing SublimeClang:

Installing SublimeClang on Linux turned out to be problematic as there are Python related issues. In order to fix the “ctypes can’t be imported” error you should follow these instructions. Unfortunately, I got some compilation errors and was not able to install the 2.6 python version. A workaround, which I found out to work quite nicely, is to install the  2.6.7 version.

Setting up SublimeClang:

Once SublimeClang is installed you should have a look at the default settings file and put the options you need in the user settings file. This is a copy of my user settings file:

    // Whether or not the plugin is enabled. Useful if you want to disable
    // the plugin completely for a specific project.
    "enabled": true,
    // Whether or not to hide the clang output panel when it's empty
    "hide_output_when_empty": true,

    // Delay in ms until recompiling the file after the buffer is modified
    // Set to 0 to disable.
    // You probably also want to change the reparse_use_dirty_buffer
    "recompile_delay": 0,

    // Whether or not to inhibit the Sublime Text 2 built in word completions
    "inhibit_sublime_completions": false,

    // Whether to use the saved file or the (possibly) dirty buffer contents when reparsing
    "reparse_use_dirty_buffer": false,

    // Whether or not fast completions are enabled. Usually you'd put
    // "sublimeclang_enable_fast_completions": false, in the project
    // settings if it's problematic in that project. You can also
    // runtime toggle fast completions alt+d,alt+f, however if it
    // is disabled for the current project (or globally in your
    // user settings) it will not be enabled. In other words
    // this setting, when set to false, overrides whatever the
    // keyboard toggle is set to.
    "enable_fast_completions": true,

    // When set to true will output the final options used to the python console
    "debug_options": false,

    // Number of worker threads to create. If set to -1 it'll create
    // one thread per cpu
    "worker_threadcount": 8,

        // For example, you can use "c++": ["-std=c++11"] to enable C++11 features.
        "c++" : ["-std=c++11"]

        "-isystem", "/usr/include/c++/4.7.2",

The final step is to append the following options to your project settings file so that SublimeClang knows where to search for you custom headers. Do not forget a comma before the “settings” item, otherwise the project file will have incorrect syntax.