Official URL: Sublime Text. Findings: Sublime Text is the best coding editor for beginners. Especially it is best for HTML and PHP. Apart from that, it supports many other programming languages as well. Install compiler if you don’t have it. I would suggest use MinGW compiler for Windows because Windows doesn’t have a GNU compiler for C language. After installing, set the path variable to the location where you have installed the compiler. Now Open Sublime Text Editor. Go into Tools Build System New Build System. Copy this code into the file.
C Compiler For Mac
- There is a menu in Sublime Text dedicated to all of the “Goto” functionality within this text editor. This is a much more fully-featured version of Visual Studio’s own “Go to” menu. Some of the highlights include Goto Symbol (added in Sublime Text 3), which lets you easily find all examples of symbols within a file.
- Here, I'm assuming that you already have the Sublime Text installed. Get it from sublimetext.com otherwise. Sublime Text has it's own Package Manager and doesn't come pre-installed with it. Skip this step, if you have already installed Sublime Text Package Manager.
:boom: Robust C/C++ code completion for Sublime Text 3
Installs
- Total41K
- Win14K
- Mac8K
- Linux18K
Aug 31 | Aug 30 | Aug 29 | Aug 28 | Aug 27 | Aug 26 | Aug 25 | Aug 24 | Aug 23 | Aug 22 | Aug 21 | Aug 20 | Aug 19 | Aug 18 | Aug 17 | Aug 16 | Aug 15 | Aug 14 | Aug 13 | Aug 12 | Aug 11 | Aug 10 | Aug 9 | Aug 8 | Aug 7 | Aug 6 | Aug 5 | Aug 4 | Aug 3 | Aug 2 | Aug 1 | Jul 31 | Jul 30 | Jul 29 | Jul 28 | Jul 27 | Jul 26 | Jul 25 | Jul 24 | Jul 23 | Jul 22 | Jul 21 | Jul 20 | Jul 19 | Jul 18 | Jul 17 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 1 | 11 | 5 | 7 | 4 | 12 | 8 | 6 | 5 | 6 | 6 | 12 | 10 | 7 | 9 | 5 | 10 | 4 | 8 | 0 | 6 | 7 | 11 | 7 | 7 | 5 | 8 | 8 | 12 | 4 | 5 | 8 | 8 | 9 | 9 | 8 | 9 | 7 | 8 | 6 | 17 | 3 | 3 | 10 | 8 | 10 |
Mac | 0 | 2 | 1 | 3 | 2 | 2 | 2 | 3 | 1 | 0 | 5 | 3 | 1 | 1 | 4 | 1 | 2 | 0 | 2 | 0 | 4 | 2 | 5 | 1 | 0 | 0 | 2 | 2 | 0 | 0 | 1 | 1 | 4 | 1 | 2 | 3 | 3 | 0 | 0 | 3 | 1 | 3 | 2 | 3 | 2 | 2 |
Linux | 0 | 7 | 4 | 5 | 4 | 3 | 5 | 6 | 6 | 5 | 6 | 4 | 8 | 2 | 14 | 8 | 7 | 4 | 4 | 2 | 2 | 5 | 4 | 2 | 3 | 10 | 5 | 8 | 13 | 8 | 7 | 4 | 7 | 10 | 6 | 4 | 7 | 7 | 4 | 5 | 3 | 7 | 8 | 13 | 9 | 5 |
Readme
- Source
- raw.githubusercontent.com
Simple start in just 3 steps!
1. Install this plugin
- In Sublime Text press CTRL+Shift+P andinstall
EasyClangComplete
2. Install clang
- Ubuntu :
sudo apt-get install clang
- OSX : ships
clang
by default. You are all set! - Windows : install the latest release from clang website.
- Other Systems : use your package manager or install from clang website.
- clang website: http://llvm.org/releases/download.html
3. Configure your compiler flags and include folders
Do you use CMake?
You're in luck! The plugin will run cmake on a proper CMakeLists.txt
in yourproject folder and will use information from it to complete your code out ofthe box! For more details, read the plugin docs aboutCMake.
Don't like CMake?
Don't worry! There are plenty of ways to configure the plugin! Read the relateddocumentation page formore info!
Extensive documentation
There are so many things I want to tell you! There is so much the plugin iscapable of! Read the docs to getstarted!
Support this project!
C/C++ language servers
The below was written for clangd, but much applies to cquery and ccls as well.
CCLS
A newer project emerged from cquery.Build and install from source, see ccls wiki
Cquery
Build and install from source, see cquery wikiNote that work on cquery has stopped. Prefer using ccls or clangd.
Sublime Text C++ Compiler Machine
Clangd
To use clangd on Debian/Ubuntu, add the apt repositories described here.After that, install with e.g. apt install clang-tools-9
. The clangd executablewill have a version number suffix. For instance, clangd-9. You will thus have toadjust your 'clients'
dictionary in your user preferences.
To use clangd on Mac, use Homebrew: brew install llvm
. The clangd executablewill be present in /usr/local/Cellar/llvm/version/binYou probably need to install the Xcode developer command-line tools. Run the following in a terminal:
And if you're on macOS 10.14, also run the following to install essential headers like wchar_t.h
:
To use clangd on Windows, install LLVM with the LLVM installer,and then add C:Program FilesLLVMbin to your %PATH%.
Compilation database
For any project of non-trivial size, you probably have a build system in placeto compile your source files. The compilation command passed to your compilermight include things like:
- Include directories,
- Define directives,
- Compiler-specific flags.
compile_commands.json
Like any language server, clangd works on a per-file (or per-buffer) basis. Butunlike most other language servers, it must also be aware of the exact compileflags that you pass to your compiler. For this reason, people have come up withthe idea of a compilation database.At this time, this is just a simple JSON file that describes for eachtranslation unit (i.e. a .cpp
, .c
, .m
or .mm
file) the exactcompilation flags that you pass to your compiler.
It's pretty much standardized that this file should be calledcompile_commands.json
. clangd searches for this file up in parentdirectories from the currently active document. If you don't have such a filepresent, most likely clangd will spit out nonsense errors and diagnostics aboutyour code.
As it turns out, CMake can generate this file for you if you pass it thecache variable -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
when invoking CMake. It willbe present in your build directory, and you can copy that file to the root ofyour project. Make sure to ignore this file in your version control system.
If you are using a make-based build system, you could use compiledbto generate a compile_commands.json
.
Since header files are (usually) not passed to a compiler, they don't havecompile commands. So even with a compilation database in place, clangd willstill spit out nonsense in header files. You can try to remedy this byenhancing your compilation database with your header files using this project called compdb.
To generate headers with compdb, read this closed issue.
You can also read about attempts to address this on the CMake issue tracker, along with the problemof treating header files as translation units.
compile_flags.txt
Sublime Text C++ Compiler Macro
Another way to let your language server know what the include dirs are is by hand-writing a compile_flags.txt file inyour source root. Each line is one flag. This can be useful for projects that e.g. only have a Visual Studio solutionfile. For more information, see these instructions. Creating this file by hand is a reasonable place to start if your project is quitesimple.