Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /homepages/28/d448670958/htdocs/wp-content/plugins/latex/latex.php on line 47

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /homepages/28/d448670958/htdocs/wp-content/plugins/latex/latex.php on line 48

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /homepages/28/d448670958/htdocs/wp-content/plugins/latex/latex.php on line 47

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /homepages/28/d448670958/htdocs/wp-content/plugins/latex/latex.php on line 48

VIM was good for years for me, but I moved to sublime_text 3 when I realized how useful this editor is and how easy it is to extend this editor with more functionalities.

Now, I edit in sublime_text and compile in the same application. I have made a syntax highlighter that shows the error in a nicer way, and if you click on the error it takes you to the place where the error happened.

Follow these steps and coding in c++ would be much simpler than before for you.

So after installing sublime_text and running it once you get a folder ~/HOME/.config/sublime-text-3/. If you aren't familiar with sublime_text it suffices to say that you can add your modifications into this folder ~/HOME/.config/sublime-text-3/Packages/User. Let's call this folder $SUBLIME_CONFIG_DIR from now on. What I am going to show you in here is how to add a build system for C++ and how to syntax highlight the output. # Setting Up the Build System Create your build system by adding a file named c++build.sublime-build to $SUBLIME_CONFIG_DIR with the following contents:

{
"shell" : true,
"cmd": ["make $file_base_name"], "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"selector": "source.c++",
"working_dir": "${file_path}", "syntax" : "Packages/User/c++output.tmLanguage" }  I will explain what each line does. 1. "shell":true simply says that sublime should run a shell command if you call build on a file. 2. cmd will be executed when build is invoked. You can use g++ or anything else instead of make. This build configuration that I have put here is a starting point, you can modify it and make it do what you want. 3. selector tells sublime which files will automatically use this build (in this case all c++ files) 4. workig_dir I set it to current directory to make it easier 5. syntax when you build your file the output will be shown in the output view as plain text with no syntax highlighting. In here I am going to use C++output.tmLanguage file which I will explain later which helps you obtain a better highlighted output for easier debugging. 6. file_regex matches the error lines in the output and if there is an error, and you double-click on the error it takes you to the corresponding file. # Adding a New Syntax There are various ways of adding new syntax highlighter to sublime. You can use JSON and then convert it to PList, you can use PList directly. For simplicity just copy the following in a file called c++output.tmLanguage. tmLanguage files are picked automatically by sublime_text at startup of the application to highlight files. the content should be as follows: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>fileTypes</key> <array> <string>ssraw</string> </array> <key>name</key> <string>Mazanin</string> <key>patterns</key> <array> <dict> <key>match</key> <string>\b(error)\b</string> <key>name</key> <string>invalid.illegal</string> </dict> <dict> <key>match</key> <string>(warning|instantiation|note|required|candidate)</string> <key>name</key> <string>markup.quote</string> </dict> <dict> <key>match</key> <string>^.*:[0-9]+</string> <key>name</key> <string>support.variable.mazanin</string> </dict> <dict> <key>begin</key> <string></string> <key>endCaptures</key> <dict> <key>0</key> <dict> <key>name</key> <string>punctuation.definition.mazanin</string> </dict> </dict> <key>name</key> <string>comment.mazanin</string> <key>patterns</key> <array> <dict> <key>match</key> <string>\\.</string> <key>name</key> <string>source.mazanin</string> </dict> </array> </dict> <dict> <key>begin</key> <string></string> <key>endCaptures</key> <dict> <key>0</key> <dict> <key>name</key> <string>punctuation.definition.mazanin</string> </dict> </dict> <key>name</key> <string>storage.mazanin</string> <key>patterns</key> <array> <dict> <key>match</key> <string>\\.</string> <key>name</key> <string>source.mazanin</string> </dict> </array> </dict> </array> <key>scopeName</key> <string>source.cerr</string> <key>uuid</key> <string>ca03e751-04ef-4330-9a6b-9b99aae1c418</string> </dict> </plist>  Remember to replace the uuid above with a unique uuid. But how do you get one. Open sublime-console and type in the followings: import uuit uuid.uuid4()  Now you are basically done. Open your c++ file, call build on that and you should be able to see the error highlighted and clickable as follows (I use Dawn theme). I personally prefer to wrap the lines of the output error and unwrap them fast so I have added this shortcut in my keymappings in $SUBLIME_CONFIG_DIR/Default (Linux).sublime-keymap which says:

[
{
"keys": ["ctrl+shift+l"], "command": "toggle_setting", "args": {"setting": "word_wrap"}
}
]


Now if you prese ctrl+shift+l you can simply wrap/unwrap the output This is more useful in most of the cases when the errors are long and the information is not helpful. The above example without wrapping would look like: