I have been trying off and on for over a year now to use Emacs as a C/C++ IDE. I have only been marginally successful thus far, but have run into a few brick walls along the way. Currently I am trying to use CEDET, but I am having a rough time understanding how to use it effectively.

The features that I am looking for in an IDE are as follows:

  1. Management of software "projects." I want my IDE to have a sense of all of the files that make up my current project so that I can perform functions like search-and-replace within my project. (It would be nice if I could also achieve this without littering my source tree with lots of support files. Why do I need more than one centralized project file per project?)
  2. The ability to build the current project from within the IDE, regardless of which buffer I am currently visiting. I need to be able to bind a key which will build the current project.
  3. Error reporting. I don't want to have to read through 500+ lines of output to find the errors that were reported by the build tools. Preferably, the errors show up in their very own buffer with one line per error.
  4. An awareness of symbols within the project, and where they are defined. I want to jump to a symbol definition whether it lives in my project files or in the system include files.
  5. Visual debugging. I want to have a watch list of local variables that update automatically as I step through the code. I want to be able to set breakpoints in the code see which line of code will be executed next.

I know that each of these features exists because I have had each of them working at one time or another using EDE, Semantic, GDB, etc. The problem is that I have never been able to have all of these features working at the same time, because each piece usually has to be configured by itself, and it is usually too much work to figure out how to configure all of them at once and make them work together.

What solutions exist for turning Emacs into a full-featured C/C++ IDE? Do you always have to configure everything piecemeal, or is there a way to set all of the features up at a time?

EDIT: A good answer to this question does not have to exactly meet all five of the given criteria. I simply provided the list to give a more concrete idea of the type of features I want to see before I would consider an IDE to be "full-featured." It is quite possible that CEDET could fit the bill, but I have yet to find a working step-by-step tutorial on how to set it up from scratch.

  • 6
    This question might be better off divided into several. You might end up having a bunch of partial answers, where none of the items are given the attention they deserve.
    – Malabarba
    Commented Sep 29, 2014 at 22:35
  • 2
    Also, item 1 might be a duplicate of emacs.stackexchange.com/questions/448/…
    – Malabarba
    Commented Sep 29, 2014 at 22:36
  • 6
    @Malabarba: If I were asking five separate questions it might be a duplicate. The whole point of this question is that there may be five different packages that achieve the five different goals, but configuring all five to play nicely with each other seems nearly impossible. If the answer comes back as "Emacs cannot function as a full-featured IDE because it takes impossible amounts of time to configure." then so be it.
    – nispio
    Commented Sep 29, 2014 at 23:13
  • 4
    Each of the points could be it's own question (potentially duplicated), putting them all together in one question can sometimes lead to different answers because of package interaction. Commented Sep 30, 2014 at 15:21
  • Related: emacs.stackexchange.com/q/3359/2264 Commented Nov 10, 2014 at 18:31

9 Answers 9


Different levels of "IDE-ness" exist for different languages, and unfortunately you're never going to get full IDE features without some configuration (if you don't like configuring things, you probably shouldn't use Emacs). CEDET aims to be a complete solution that covers all your needs for supported languages, but I've personally never gotten it working properly; instead, I use a few packages in tandem to cover my IDE bases. I'll go over your points in order, with some solutions for different languages that I know of:

  1. projectile is the closest package to providing a real IDE-like experience. It provides a ton of useful functionality on a per-project basis. You will probably also want some sort of window/workspace management; I use my own solution called wacspace, but other good solutions include perspective, workgroups, and elscreen.
  2. Different languages have different ideas of what a "build" is, but M-x compile can accommodate pretty much anything and makes paging through errors easy (just use next-error). You can easily customize on a per-project basis using directory variables to set compile-command. You can run compile with projectile using projectile-compile-project (C-c p c).
  3. M-x compile also has you covered here--errors usually end up one per line in the *compilation* buffer, with easy paging with next-error.
  4. Jumping to a symbol involves "understanding your code", and this is where support varies tremendously across languages. For Elisp, you can use the excellent elisp-slime-nav, and then M-. to jump to definition. Here are some packages that provide similar support for other languages: CIDER (for Clojure); SLIME (for Common Lisp); robe (for Ruby); semantic or clang-tags for C/C++ (disclaimer: I've never used either, so I have no idea whether they work well). If all else fails, you can also use Emacs' built-in TAGS facilities using something like exuberant ctags, but I've never had anywhere near acceptable results with TAGS.
  5. Emacs has very scattered support for debuggers. GDB with GUD is your best bet for C-like languages; otherwise, it's pretty much entirely on a per-language basis. (I don't think cross-language visual debugging is really a realistic goal.)
  • 4
    As a side-node projectile can integrated directly with perspective creating a perspective-per-project automatically on project switch. Commented Sep 30, 2014 at 13:41
  • I would add notes about semantic to #4, semantic is a great package, it understands your code and can do a lot of useful things with that information. Commented Sep 30, 2014 at 17:35
  • I've never really used semantic, and I think I remember that it has incomplete C++ support, but I've added it to the answer.
    – shosti
    Commented Sep 30, 2014 at 18:11

I used this guide to get started using Emacs as a C++ IDE. It introduces Helm and Projectile which help answer a number of your questions. To wit,

  1. Projectile manages projects. It searches up the directory tree for a Makefile, SConstruct, Git repo, SVN repo, and perhaps some other build system or version control files to automatically learn what files are associated with the current project. As an example, C-c p h runs helm-projectile which is uses Helm to find a file in the current project.

  2. Projectile can build your projects. C-c p c runs projectile-compile-project which tries to run Make/SCons/CMake based on available files. I have never had to configure this; it has always known what to do.

  3. The errors show up in their own buffer when you run projectile-compile-project but I'm not sure it is as pretty as you'd like.

  4. You can use the package helm-gtags which interfaces with the gtags program (which you should have available on your system). Note that gtags is a GNU project and so is unlikely to work immediately on Windows.

    Once configured, Helm becomes aware of symbols in the project and can navigate to definitions and use locations. For example helm-gtags-dwim can jump to any use of a variable or function, and when run on a header file opens that header file.

  5. I haven't yet tried this.

The guide listed gives very explicit configuration information on how to get started.

  • I've stumbled upon that guide, too, and applied it. IMHO it's somehow heavyweight and changes a lot of basic emacs interaction too much. I've disabled a number of helm-related configurations because they interfered with usual shortcuts (like easily opening current directory in a buffer, or opening file in a sub sub dir with a few keystrokes). Worth a look, though, but should probably be tried step by step, not as a whole. Commented Mar 10, 2017 at 10:31

Since you are asking for a full-featureed C/C++ IDE now, I might be qualified.

I used all MS IDEs from vc4 to Visual Studio 2010, so I fully understand what you want.

The good news is that Emacs could be 95% as good as Visual Studio, and it can do much more. but you might be not interested in the "more" part. So I will focus on your questions only.

Now the key point, you MUST USE CMake, even your C++ application is for windows only! End of story. No other choice, I know what I'm talking about. If you don't use CMake, then it's pointless to continue.

Answer to question 1: You don't need set up anything, install cpputils-cmake (https://github.com/redguardtoo/cpputils-cmake) which sets up other plugins. It's even more convenient than Visual Studio. So per project setup is not needed. For search replace thing, I combine the power of bash/perl/git and percol (https://github.com/mooz/percol), which is much better than any IDE. check my blog (http://blog.binchen.org/categories/emacs.html) and my ~/.bashrc (https://gist.github.com/redguardtoo/01868d7a13817c9845e8#file-bashrc). For example, I can search replace the files in certain commit.

Answer to question 2: It's already setup by cpputils-cmake, you just need M-x compile as usual.

Answer to question 3: same as question 2. I don't know why this is a problem. it's exactly the same behavior as VS, with better key bindings.

Answer to question 4: Now most people just use Gnu Global which could be combined with cpputils-cmake. I understand the real issue is detect the directories containing all included C++ headers automatically. That can be done with cpputils-cmake, everything else is easy. Please man global in shell and read manual about the environment variable GTAGSLIBPATH. There are many plugins to provide nice UX based on Global for code navigation, I recommend ggtags.el

Answer to question 5: Visual Debugging, Many people recommended M-x gdb-many-window, I tried it but it didn't work. It's simply because my gdb version is outdated (Hint, I'm using OSX 10.7.3) and I'm too lazy to upgrade my OS. But GUD is fine. I create some short key to print variable for me in the editor window. all the debug stuff is usable. It does not has table UX layout as VS. but to be honest with you. Microsoft's debugger UX is also not the best in the world. The best user friendly debugger is DDD (http://www.gnu.org/software/ddd/). Gud and VS both suck on this issue. These days I just insert logging code with yasnippet which is another Emacs plugin. To clarify, I know all the advanced tricks about breakpoints, it's just because I'm too lazy to apply these tricks. Inserting logging code in Emacs is much easier.

There are many more things about IDE: code completion? use company-mode, no setup need. real time syntax check? use cpputils-cmake, then (flymake-mode 1)

The best thing is, you need do less setup than VS if you use my setup at (https://github.com/redguardtoo/emacs.d) That setup has the title "purcell's emacs configuration plus C/C++ support".

Now there is something I need emphasize, Emacs give you full freedom. You can choose any way to start. hard way or easy way.

The easy way is just copy my setup (or anybody's setup on github, count the stars at first), in 5 minutes you will have a fully functional C++ IDE. VS has not finished start up in that 5 minutes.

The hard way is tweaking the setup from the scratch. If you choose the hard way, then don't complain Emacs. It's your choice.

BTW, in the long run, a little bit Emacs Lisp knowledge might be helpful. I think it's trivial for a professional C++ developer compared the time I wasted on MS sh*t. Many years ago MS silently upgraded their VC runtime in some windows update. It made my product running OK on company's machines but crashed on customers' computers.

After that incident, I began to understand Richard Stallman.

  • 2
    Interesting. "you MUST USE CMake" -> So, you're telling that when working on a random free software package that uses autoconf or personal script, one should write a wrapper CMakeLists.txt ? Commented Mar 10, 2017 at 10:36
  • 1
    You can use GNU Global instead, not as perfect as cmake solution. But more flexible, see blog.binchen.org/posts/emacs-as-c-ide-easy-way.html
    – chen bin
    Commented Mar 10, 2017 at 16:01

For #4, I highly recommend exuberant-ctags and the built-in tags support, which I have used for years. Alternatively, I just recently have switched to using GNU Global and the ggtags package and have found them to be slightly superior; although, they function almost identically. Both work with nearly no configuration. For other IDE features, I also like the auto-complete package. Likewise, I use M-x compile extensively and bind global keys to next and previous error. For searching within "projects", I generally just use M-x find-grep. Note that it will use the same key bindings for next and previous error.


Management of software "projects." I want my IDE to have a sense of all of the files that make up my current project so that I can perform functions like search-and-replace within my project. (It would be nice if I could also achieve this without littering my source tree with lots of support files. Why do I need more than one centralized project file per project?)

Projectile seems the best option for project management in emacs. It is extremely lightweight, you do not need to add any extra file to your project. It will try to automatically detect projects for you based on presence of certain special files. For example - if you are working in a git repo, projectile will treat it as a project (any files tracked by git will be treated as part of project), then you will be able to use commands like projectile-find-file to open any file the project. It has a bunch of other command which operate on per project basis.

Error reporting. I don't want to have to read through 500+ lines of output to find the errors that were reported by the build tools. Preferably, the errors show up in their very own buffer with one line per error.

Flycheck has support for checking syntax using clang/gcc.

An awareness of symbols within the project, and where they are defined. I want to jump to a symbol definition whether it lives in my project files or in the system include files

I would recommend you to take a look at rtags. It uses clang as a backend and a pretty good job of jumping to definition and completion. It may also help you with #3 since it also integrates with flymake to display error and warnings using clang. Besides it has some limited support for refactoring. Another option for intelligent auto-completion is irony-mode


The CEDET version currently shipped with Emacs is difficult to setup, but the one you can get on the official site is easier to setup, and could answer to your #2 and #4 needs.

CEDET's EDE allows you to manage for example makefile and automake projects, adding targets to it, and associating files to targets. You can then compile your project using EDE commands. As it uses the Emacs' built-in compilation mode, your need #3 is satisfied too.

CEDET's Semantic has parsers for several languages, including C++. It can retrieve the tags defined in a file, like exuberant-ctags and GNU Global, but it has also accurate auto-completion and jumping features. If you have two methods called "foo", Semantic's jump is smart enough to bring you on the right one.

For #1, I personally use projectile, and I succesfully used GDB for #5 some times ago.

Hint for #3: If EDE is overkill to you, Emacs has the command M-x recompile to launch your last compile command, so you can run your compilation one first time, and then use recompile in any buffer.


For #4, seems to be a new project called YouCompleteme, and the corresponding Emacs client which seems to be the next cool thing. Because it uses clang it has a better view of the code than tags or global.

  • 1
    Thanks for the suggestion, but since I am looking for things that integrate well together I'm not sure that attempting to get one of the features by using a Vim plugin with a prototype Emacs client is the best starting point.
    – nispio
    Commented Oct 3, 2014 at 14:02
  • 3
    Try github.com/abingham/emacs-ycmd instead for the emacs client (note it uses github.com/Valloric/ycmd, not github.com/Valloric/YouCompleteMe). It works with company-mode (recommended by other answers here) so it does integrate well with the rest of Emacs. You can install ycmd and company-ycmd from MELPA ( sprunge.us/LXGY is my config); and follow the build instructions for ycmd. The only challenge is you need to put your compile flags into a file like github.com/Valloric/ycmd/blob/master/examples/…
    – unhammer
    Commented Nov 20, 2014 at 9:26

I've been happy with CEDET from its source repo + ECB + gtags +cscope. That said, there are many suggestions on this post that I will be trying.

  • 1
    Could you expound on what you had to do to make all of those tools work together?
    – nispio
    Commented Oct 8, 2014 at 4:58
  • 4
    Right now this almost looks like a misplaced comment. :-) If you would be do kind, please elaborate a bit.
    – Malabarba
    Commented Oct 8, 2014 at 6:12
  • Sorry about being terse. The StackExchange App takes dome getting used to. This solution answers #4, dealing with symbol navigation and analysis of the source. CEDET, of course, contains semantic. ECB is the Emacs Code Browser, and uses CEDET to list methods and report symbol info. Gtags and Cscope both build tables of symbol information from the source base (helm also does this), and integrates with Emacs to allow navigation by tags or symbol. Commented Oct 8, 2014 at 14:48

As has been mentioned in pieces above, projectile (optionally with helm) is a brilliant solution for project management.

Ycmd is great for code completion and some navigation, and the best client for it is emacs-ycmd (full disclosure: I wrote the emacs client.)

For "tags" and indexing, the best overall solution I've found is codesearch (more disclosure: I wrote this one, too.) It's fairly dumb in that it really just does regex searching, but it's blazingly fast and generally all you need, and it works well across multiple languages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.