Neovim for Beginners — Print Debugging

Simple debugging using the print statement.

4 min readAug 17, 2022


Neovim for Beginners — Print Debugging

We talked about debugging in several articles in this series. Sometimes debugging can be simple. E.g., we may just want to print out some variables for inspection.

In this article, let’s explore plugins that make print debugging easier for us.

This article is part of the Neovim for Beginners series.

The Neovim configuration files are available in this repository.

Getting Started

Using print statements for debugging is simple and yet controversial. Writing good unit tests, practicing test-driven development (TDD), using proper logging, and test automation are better software engineering practices.

However, this simple debugging technique could be useful, e.g., when we are doing rapid prototyping or competitive programming. We will check out several plugins that make the injection and removal of these print statements easier.


We talked about the refactoring.nvim plugin in the refactoring article. Besides refactoring, this plugin also provides features for print debugging.

  • printf — Automated insertion of print statement to mark the calling of function.
  • print_var — Automated insertion of print statement to print a variable at a given point in the code, supporting both visual and normal modes.
  • Cleanup: Automated cleanup of all print statements generated by the plugin.

We already installed the plugin using packer.nvim in the lua/plugins.lua file.

In the lua/config/whichkey.lua file, we configure the key mappings for normal and visual modes.




Software engineer, Data Science and ML practitioner.