DEV Community

Colin Bartlett
Colin Bartlett

Posted on • Originally published at vimtricks.substack.com

1 1

VimTrick: Relative line numbering

Many operations in Vim can be executed over a given number of lines. For example, d3j will delete the current line, plus the 3 below it. Having line numbers displayed will make it easier to know how many lines you want to edit. You can enable and disable line numbering easily in Vim:

  • :set number - Shows line numbers
  • :set nonumber - Hides line numbers

You may find yourself often reading the line numbers and then subtracting two numbers in your head to decide over how many lines to execute a command. But there is a better way!

Vim allows showing relative line numbers instead of absolute line numbers:

  • :set relativenumber - Shows relative line numbers
  • :set norelativenumber - Hides relative line numbers

Alt Text

We have more screenshots and details over on our VimTricks post.

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay