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

Heroku

Built for developers, by developers.

Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly — using the tools and languages you already love!

Learn More

Top comments (0)

DevCycle image

Ship Faster, Stay Flexible.

DevCycle is the first feature flag platform with OpenFeature built-in to every open source SDK, designed to help developers ship faster while avoiding vendor-lock in.

Start shipping