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
webdevetc profile pic
webdevetc

I am a 29 year old freelance backend web developer from London, mostly focusing on PHP and Laravel lately. This is my site - I mostly write about PHP here. Contact me here (especially for any contracting/freelance PHP jobs early 2019 in London ;) ).

Leave a Comment