Vim tip: The best line number config (current + relative line numbers)

Vim tip: The best line number config (current + relative line numbers) Thumbnail image

Everyone has their own preferences for config/.vimrc options, but for me I think that having the current line number and relative line numbers is the most useful way to use Vim.

The current line number is always shown in the left gutter, along with the relative line numbers above/below.

This is useful when wanting to move a to a certain line above/below the current line. You can use keyboard shortcuts (e.g. to move 5 lines down: 5j

See the screenshot above to make sense of what I'm trying to say, if it isn't clear.

This is the config to add to your .vimrc to get it working:

  1. :set relativenumber
  2. :set number
  3. :set number relativenumber

Subscribe to my spam free newsletter for other Laravel and Vue updates like this

I never spam, and only email when I have a good in-depth post published on my site (mostly about Laravel and Vue). You can also follow me on social media to get updates.

webdevetc profile pic

I've been working as a software developer for many years (with the last few years specialising in Laravel and Vue). I mostly write about PHP and JavaScript/TypeScript on this site. Contact me here. Need to hire a contract software developer in London, UK (or freelance)? Contact me and check my availability.

Leave a Comment