CMake Support for Vim

Incorporates the functionality of CMake into Vim.

Download .zip Download .tar.gz View on GitHub

Stories in Ready

CMake Project Support in Vim

With the power of gray skull, CMake support in Vim is born. This allows for CMake commands for building, installing, cleaning and invoking custom targets within Vim. It makes uses of vimux if found and can provide integrations for Syntastic and YouCompleteMe.

cmake.vim 0.4.6 is a Vim plugin that allows you to use CMake within Vim for your projects. This is alpha-grade software and may turn your CMake project into a cat-overrun Telnet session.

If lost, run :help cmake for a bit of guidance.


At the time of writing, cmake.vim has been tested with Vim 7.3+ in nocp mode and CMake 2.8.


I recommending using Vundle to install plugins. The line necessary to add this plugin is as follows:

Bundle 'jalcine/cmake.vim`

Getting Started

After you installed the plugin, just cd into the directory where the top-level CMakeLists.txt can be found and run:

" Create a new binary directory for your clean project.
:CMakeCreateProject <build-dir-name>

" Build all of the targets.

With that, you created (or re-configured in a vanilla-setup) a new binary directory and built the project.


cmake.vim defines a few methods for generic interaction with CMake. Check out :help cmake-methods for more information.


In order for CMake to operate, it has to know where the build directory is located. This is done automatically by the plugin but it does need help in the event that you happen to build your CMake project in a sub-directory. Check out :help cmake-options for more information.


See :help cmake-integrations for tips on integrations cmake.vim with other plug-ins like Syntastic or YouCompleteMe. Long story short, it's freaking awesome but could use some work. With this version, the integrations are now target-specific, allowing for fine-grained integration for every single file.

Known Issues

  • With the more recent changes to YouCompleteMe; it's become a bit difficult to dynamically add per-file flags. See :h cmake-integrations-ycm-setup on how to configure YouCompleteMe with CMake.

  • Getting and setting variables is still rough around the edges.


[+] Provide :CMakeBuildTarget that'd build the target provided. If a file is to be provided, find the target for that file and build the target it belongs to (restricted to source files). * Also for :CMakeCleanTarget since we can determine pre-target cleaning information. [+] Improve integration's use flag lookup and discovery on a per-target basis and a per-file basis (restricted to source files). [+] Pass an argument string to :CMakeCreateBuild. [+] Allow setting and getting values using :CMakeGetVar and :CMakeSetVar.

  • Expose cmake.vim's buffer commands only in worthy buffers.


The test suite is written using RSpec and Vimrunner. The following would do a full unit test of the entire system:

bundle install


This code is released and available under the MIT license. Multiply and be fruitful.


I'm Jacky Alcine and I like code. A lot. I also chat a lot like a firehose so follow with caution!

Bitdeli Badge