LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-28-2012, 05:42 PM   #1
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, (Which Exit LOL), USA
Distribution: Centos 6.7 Under VMware in Win7
Posts: 473

Rep: Reputation: 34
Showing Line Numbers in the VI Editor


Greetings.

I would like to have line numbers showing when I use the VI editor.

Can anyone advise how to do this.

I'm a newbie that's why I'm asking here.

Thanks
 
Old 08-28-2012, 05:44 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,396

Rep: Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395
http://www.cyberciti.biz/faq/vi-show-line-numbers/
 
Old 08-28-2012, 05:52 PM   #3
Renante
LQ Newbie
 
Registered: Aug 2012
Location: Ottawa ON, Canada
Distribution: Red Hat Enterprise Linux 6.3 Server
Posts: 13

Rep: Reputation: 2
Quote:
Originally Posted by swamprat View Post
Greetings.

I would like to have line numbers showing when I use the VI editor.

Can anyone advise how to do this.

I'm a newbie that's why I'm asking here.

Thanks
on vi command, type: set number

To make that permanent, edit your ~/.vimrc -- vi ~/.vimrc

If you plan to use vi in programming (C, C++, ...):
syntax on
set number
set cindent
set expandtab
set tabstop=2
set shiftwidth=2
set softtabstop=2
 
Old 07-14-2017, 10:45 AM   #4
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, (Which Exit LOL), USA
Distribution: Centos 6.7 Under VMware in Win7
Posts: 473

Original Poster
Rep: Reputation: 34
Greetings,

Although there have been a number of replys to my post, after installing CentOS 7 I can no longer find my .vimrc file.

I tried to create a new file in MY root directory by making a copy of and example I found in the system. That too didn't work.

Any help will be appreciated. Am I looking for the .vimrc file in the wrong place? Thanks
 
Old 07-14-2017, 12:04 PM   #5
justmy2cents
Member
 
Registered: May 2017
Location: U.S.
Distribution: Un*x
Posts: 227
Blog Entries: 2

Rep: Reputation: Disabled
Just make make a .vimrc file in your /home/user directory, and put set number in it for the display of line numbers..

Last edited by justmy2cents; 07-14-2017 at 12:06 PM.
 
1 members found this post helpful.
Old 07-15-2017, 11:22 AM   #6
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, (Which Exit LOL), USA
Distribution: Centos 6.7 Under VMware in Win7
Posts: 473

Original Poster
Rep: Reputation: 34
Thanks justmy2cents. I don't see a /home/usr/ directory. When I'm in the root directory and I give the ls command I do see a usr directory.
 
Old 07-15-2017, 12:30 PM   #7
aragorn2101
Member
 
Registered: Dec 2012
Location: Mauritius
Distribution: Slackware
Posts: 475

Rep: Reputation: 225Reputation: 225Reputation: 225
Quote:
Originally Posted by justmy2cents View Post
Just make make a .vimrc file in your /home/user directory, and put set number in it for the display of line numbers..
He means:

If your username is user1234 for example, you will put the vim config file at
Code:
/home/user1234/.vimrc
And you might want to check this out as well: http://vim.wikia.com/wiki/Display_line_numbers
 
1 members found this post helpful.
Old 07-15-2017, 02:14 PM   #8
scasey
Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 5.11
Posts: 335

Rep: Reputation: 122Reputation: 122
and maybe this
Code:
man vim
since you've asked a couple of questions about vim recently.

Last edited by scasey; 07-15-2017 at 02:15 PM.
 
Old 07-15-2017, 11:24 PM   #9
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, (Which Exit LOL), USA
Distribution: Centos 6.7 Under VMware in Win7
Posts: 473

Original Poster
Rep: Reputation: 34
It now works using my user id. Now I'll do the same by putting a copy of this in my etc directory so another doesn't have to include it under their user id. Thank you all for helping with this.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Trying to number every other line and append those numbers to end of line kmkocot Programming 7 04-23-2010 11:17 AM
Grep's line numbers parsed into one line of output. judgex Programming 8 08-14-2006 04:22 AM
Prepend # for certain line numbers in VI twantrd Linux - Software 3 09-05-2005 01:27 PM
printing line numbers? fisheromen1031 Programming 1 07-27-2004 02:19 PM
line numbers in kdevelop febisfebi Programming 1 02-18-2004 07:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration