DEV Community

Pavol Z. Kutaj
Pavol Z. Kutaj

Posted on

Explaining Null Device or Black Hole Register in Vim

The aim of this page📝 is to explain the concept of registers in Vim, particularly the black hole register, and its comparison to /dev/null in Bash. I am solving an incident where our design has something similar in event streaming context — we have a stream that works like a null device and we write data there in when it has to be written but it is just to discard it. In general, this is known as null device

  • Vim has a special register called the black hole register.
  • The black hole register discards data without storing it.
  • Use _ (underscore) to specify the black hole register.
  • Example commands: "_d (delete without storing), "_x (delete character) or "_C" to change the whole line without yanking its contents to a register
  • This concept is similar to redirecting to /dev/null in Bash.
  • /dev/null discards data without saving it.

Example in Bash:

echo "This won't be seen" > /dev/null
Enter fullscreen mode Exit fullscreen mode

Example in Vim:

"_d
"_x
"_C
Enter fullscreen mode Exit fullscreen mode

LINKS

Billboard image

Synthetic monitoring. Built for developers.

Join Vercel, Render, and thousands of other teams that trust Checkly to streamline monitor creation and configuration with Monitoring as Code.

Start Monitoring

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

đź‘‹ Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay