DEV Community

SpaceVim
SpaceVim

Posted on • Originally published at spacevim.org on

3 3

Use Vim as a C/C++ IDE

Use Vim as a C/C++ IDE

This is a general guide for using SpaceVim as a C/C++ IDE, including layer configuration and usage. Each of the following sections will be covered:

  • Enable language layer
  • code completion
  • alternate file jumping
  • code running
  • code format
  • REPL support <!-- vim-markdown-toc --> ### Enable language layer

To add C/C++ language support in SpaceVim, you need to enable the lang#c layer. Press SPC f v d to openSpaceVim configuration file, and add following configuration:



[[layers]]
  name = "lang#c"



Enter fullscreen mode Exit fullscreen mode

for more info, you can read the lang#c layer documentation.

code completion

By default the autocomplete layer has been enabled, so after loading lang#c layer, the code completionfor C/C++ language should works well.

alternate file jumping

To manage the alternate file for a project, you may need to create a .project_alt.json file in the root of yourproject.

for exmaple, add following content into the .project_alt.json file:



{
  "*.c": {"alternate": "{}.h"},
  "*.h": {"alternate": "{}.c"}
}



Enter fullscreen mode Exit fullscreen mode

with this configuration, you can jump between the alternate file via command :A

code running

The default code running key binding is SPC l r. It will compile and run current file asynchronously.And the stdout will be shown on a runner buffer.

c-cpp-runner

code format

The format layer use neoformat as default tool to format code, it will format current file.And the default key binding is SPC b f.



[[layers]]
name = "format"

Enter fullscreen mode Exit fullscreen mode




REPL support

Start a igcc inferior REPL process with SPC l s i. After the REPL process being started, you cansend code to inferior process, all key bindings prefix with SPC l s, including sending line, sending selection or evensend whole buffer.

c_repl

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →