Skip to content

Instantly share code, notes, and snippets.

Last active April 19, 2022 00:15
Show Gist options
  • Save yegappan/1e88a9aed4f9f266d91d768b633487f3 to your computer and use it in GitHub Desktop.
Save yegappan/1e88a9aed4f9f266d91d768b633487f3 to your computer and use it in GitHub Desktop.
My development process for contributing to Vim
I use the below described development process and tools for developing Vim features.
I use a Ubuntu system for most of the development. But the tools mentioned below
are also available on MacOS.
1. Clone the Vim source code from
2. Modify src/Makefile to enable additional compiler diagnostics:
CFLAGS=-Wall -Wextra -pedantic
3. Modify src/Makefile to enable the address and undefined sanitizers:
SANITIZER_CFLAGS=-g -O0 -fsanitize=address,undefined -fno-omit-frame-pointer
4. Configure and build Vim:
$ cd vim
$ ./configure --with-features=huge
$ make
5. Make the source code changes and build Vim.
6. Develop the feature test scripts under the src/testdir directory and
test the feature:
$ cd vim/src/testdir
$ make test_<feature>.res
7. Use the code coverage tool (LCOV -
to measure the code coverage and add additional test cases.
Modify src/Makefile to uncomment the following lines:
PROFILE_CFLAGS=-g -O0 -fprofile-arcs -ftest-coverage
Build and run Vim.
$ cd vim/src
$ make clean
$ make
$ ./vim
Run the following command to create a baseline code coverage:
$ cd vim/src
$ lcov -c -i -b . -d objects -o objects/
Run the Vim test scripts to test the feature. Run the following
command to see the code coverage:
$ cd vim/src
$ lcov -c -b . -d objects/ -o objects/
$ lcov -a objects/ -a objects/ -o objects/
$ lcov genhtml objects/ -o objects
This will load the code coverage results in a browser. Based on
the code coverage, modify the test scripts to add additional
After completing this, update the src/Makefile to remove the
profiling related lines and rebuild Vim.
8. Use valgrind ( to check for memory leaks.
Edit src/Makefile to free all the memory when exiting Vim:
Rebuild Vim.
$ cd vim/src
$ make
Edit the src/testdir/Makefile to enable valgrind:
VALGRIND=valgrind --tool=memcheck --leak-check=yes --num-callers=25 --log-file=valgrind.$*
Run the test script:
$ make test_<feature>.res
Check the valgrind.test_<feature> file for any memory leaks. Fix any
reported memory leaks and repeat these steps.
9. Run static analysis using the CLANG checker (
Configure Vim using the checker:
$ scan-build ./configure --with-features=huge
$ scan-build make
Run scan-view to view the static analysis results:
$ scan-view <name of the file from the scan-build output>
Fix any static analysis warnings and repeat the steps.
10. Use the Cyclomatic Complexity Analyzer tool lizard (
to analyze the code.
$ cd vim/src
$ -s nloc <Vim source file>
Refactor the source code to reduce either the number of lines or to
reduce code complexity and rerun the tool.
11. Commit the code to Github and create a pull request.
12. Check the Vim Travis CI builds (
and the Vim Appveyor builds (
for any problems.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment