3

I am using the VI editor in Ubuntu and I have maximum usage of VI editor. to see the line number in vi i am using like below:

:set nu 

I want to set it default when I open a file in vi editor, that file text open with line number by default.

is it possible?

Sorry for duplicate's if it but I search it lot first but not found easily also tried :colorscheme now it is showing me unknown

Ramesh Chand
  • 7,274
  • 4
  • 33
  • 37

1 Answers1

12

You could add this to your ~/.vimrc file:

set number

But if you want that to happen only on files with txt extension:

autocmd BufReadPost *.txt set number

or perhaps better, on any file which Vim detects is a text file:

autocmd FileType text set number
joeytwiddle
  • 1,957
  • Thanks @joeytwiddle it works !! just tried by editing # vi ~/.vimrc and enter set number in the file and Save it by :wq! – Ramesh Chand Jan 08 '16 at 10:50