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
We have more screenshots and details over on our VimTricks post.
Top comments (0)