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

3
  • 1
    By the way, you might like to ask Vim-related questions on the Vi and Vim StackExchange site – joeytwiddle Jan 8 '16 at 9:28
  • vi ~/.vimrc Error detected while processing /root/.vimrc: line 3: E185: Cannot find color scheme ':default' – Ramesh Chand Jan 8 '16 at 10:46
  • O.o You don't have to use those settings - the relevant point is that ~/.vimrc is the file to be modified. – muru Jan 8 '16 at 10:50
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
1
  • 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 8 '16 at 10:50

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