Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

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

share|improve this question

marked as duplicate by muru, DevRobot, Fabby, Eric Carvalho, David Foerster Jan 11 at 2:48

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
By the way, you might like to ask Vim-related questions on the Vi and Vim StackExchange site – joeytwiddle Jan 8 at 9:28
    
vi ~/.vimrc Error detected while processing /root/.vimrc: line 3: E185: Cannot find color scheme ':default' – Ramesh Chand Jan 8 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 at 10:50
up vote 8 down vote accepted

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
share|improve this answer
    
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 at 10:50

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