This question might seem identical to This One but its not.
I can :set number from within a file I'm editing but how can I have them always be on by default?
Now as per that answer its recommended to add set number
to ~/.vimrc file. But you see there's no such file in my home file. From this question I tried to create that .vimrc file. It works and line number is shown. But problem is then all code highlighting is gone. How to resolve this? How to show line number with keeping code highlighting?
Asked
Active
Viewed 2,640 times
2

Community
- 1
- 1

Milon Sarker
- 478
- 8
- 25
-
Add `syntax on` to your `.vimrc` file. – Meninx - メネンックス Mar 05 '17 at 15:25
-
1I did and its working perfectly. Thanks a lot. @Meninx-メネンックス – Milon Sarker Mar 05 '17 at 15:30
-
which version? e.g. `8.0.386` works just fine. – Gang Mar 05 '17 at 15:31
-
version 8.0.329 @Gang – Milon Sarker Mar 05 '17 at 15:32
-
1@Leon, mine in fedora 25 build have syntax on by default – Gang Mar 05 '17 at 15:36
-
2Possible duplicate of [vim line numbers - how to have them on by default?](http://stackoverflow.com/questions/10274146/vim-line-numbers-how-to-have-them-on-by-default) – Herb Mar 05 '17 at 22:15
-
its not duplicate. i mentioned about those questions in my question. @HerbWolfe – Milon Sarker Mar 06 '17 at 15:34
-
The focus of your question, based on the title is getting line numbers to always be on. That is an exact duplicate of the questions you referenced. – Herb Mar 06 '17 at 15:38
2 Answers
4
Add set nu
and syntax on
to your .vimrc
echo 'set nu' >> ~/.vimrc
echo 'syntax on' >> ~/.vimrc

sa77
- 3,563
- 3
- 24
- 37