Category Archives: Programming Tools

Use SingleCompile to Compile and Run a Single Source File Easily in Vim

Last updated on October 1, 2016

Although Vim itself has already been a very powerful text editor, its plugins make it even better. SingleCompile is a plugin aimed at making it more convenient to compile or run a single source file without leaving Vim.

Consider this situation: you’ve just written a small C file (or small python script) with Vim for some tiny test, then you need to use :!gcc %:p to compile the C source file and run the executable with :!./a.out command (Or use :!python %:p to run the python script). Although a key mapping could make this process a bit convenient, but many of Vim’s advanced features will become unavailable, such as quickfix, compiler feature. SingleCompile was born to solve this problem, making this process more convenient and powerful than simply defining a few key mappings:

  • Compile or run the source file quickly using quickfix feature and compiler feature of Vim;
  • Auto detecting compilers and interpreters;
  • Fast switch between several installed compilers or interpreters;
  • Multi-language support;
  • Custom your own compiler/interpreter template;
  • View the result of last run command at any time(requires tee command);
  • Run the compiled program asynchronously and view the result at any time (see :SCCompileRunAsync in the help file).

Let’s see more about SingleCompile.

Continue reading