3

I am working on RHEL 6.6. When i open vim editor and set numbers, the line numbers appear but there is a very big indentation from the left side of the screen. is there a way to reduce that gap: Here is a sample:

  1 #!/bin/sh
  2
  3 echo "Hello World"
  4
  5 echo "bye"

Its almost 6 spaces empty to the left of numbers 1, 2, 3 ...

I tried googling but could not find an answer to this problem (though found some other useful commands around vim)

enter image description here

Here is the image for set numberwidth: enter image description here

Here is the image for vim version: enter image description here

  • 1
    I really don't think you tried googling hard enough. :h 'numberwidth' – nanny Dec 29 '15 at 18:09
  • nanny - ":h numberwith" did not work, i get the following error: E435: Couldn't find tag, just guessing! – JavaTec Dec 29 '15 at 18:25
  • You must have typed it in wrong. You need to set numberwidth in the same way that you turned on numbers in the first place. – nanny Dec 29 '15 at 19:25
  • I think you're not using full Vim, but vim-tiny, or vi. edit your question to incllude the output of vim --version. – muru Dec 29 '15 at 19:35
  • Hello muru - here is my vim version: VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Feb 17 2012 10:23:31) Included patches: 1-411. Please let me know if this suffices or i should get the entire output uploaded (and sorry for the late reply guys, i had to run multiple offices to get my DL re-instated) – JavaTec Dec 30 '15 at 15:50
3

Just adapt it with the width you want (the 4 there is the number of characters you want the number to have).

echo "set numberwidth=4" >> ~/.vimrc

Note that you must have the +linebreak compile option on in order for this to work. To check if you have this flag type :echo has('linebreak') in your vim (0 means you don't have it).

  • hi Kira - this did not change the width/margin either. i did not get any error but no change in the margin either – JavaTec Dec 29 '15 at 18:27
  • Check the updated answer. – Kira Dec 29 '15 at 18:33
  • Hi Kira unfortunately, this one also not working. Here's what i did: opened vim typed:echo has('linebreak'), no error but no change/response either. – JavaTec Dec 29 '15 at 18:45
  • Man... you've typed enter after that... Right? Also, note that the output of that command will show up right in the botton of the screen, where you have just typed. – Kira Dec 29 '15 at 19:16
  • yes Kira, i did hit enter after that command (and sorry for the late reply, i had to run multiple offices to get my DL re-instated) – JavaTec Dec 30 '15 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.