LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 06-02-2007, 01:28 AM   #1
adnanm
Member
 
Registered: Dec 2004
Location: Bosnia and Herzegowina
Distribution: Centos, FreeBSD
Posts: 49

Rep: Reputation: 15
select in vi


Hi,

I would like to select a block of line in vi editor, from line 24510 to 36542.

Any ideas?
 
Old 06-02-2007, 01:51 AM   #2
jstephens84
Senior Member
 
Registered: Sep 2004
Location: Nashville
Distribution: Manjaro, RHEL, CentOS
Posts: 2,098

Rep: Reputation: 102Reputation: 102
Try shift+v then use the arrow keys to highlight lines.
 
Old 06-02-2007, 02:03 AM   #3
adnanm
Member
 
Registered: Dec 2004
Location: Bosnia and Herzegowina
Distribution: Centos, FreeBSD
Posts: 49

Original Poster
Rep: Reputation: 15
jstephens84:

Thank you but in fact I got over 10k of lines.

So what I need is a command to do it from once.
 
Old 06-02-2007, 02:10 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
You can prepend commands with the line range.
:24510,36542s/^/\t/
will insert a tab on the range 24510-36542.
:24510,36542y
will yank this range of lines. You could also use cut instead and then 'p' paste them somewhere.
 
Old 06-02-2007, 02:27 AM   #5
adnanm
Member
 
Registered: Dec 2004
Location: Bosnia and Herzegowina
Distribution: Centos, FreeBSD
Posts: 49

Original Poster
Rep: Reputation: 15
jschiwal:

How to use cut? That is what I need.
 
Old 06-02-2007, 06:36 AM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
You can use :delete followed by aste
:10,20d
50G
]p

The :10,20d command will delete the lines from 10-20 inclusive.
Entering 50G will go to line 50.
] goes to the end of line 50
p pastes what you deleted.
 
  


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
select() Kroenecker Programming 1 03-12-2006 02:01 AM
select jhon Programming 5 11-01-2005 10:46 PM
Select() did not select my socket thvo Programming 1 05-08-2005 01:20 AM
SELECT on MySQL Help Gerardoj Programming 5 05-29-2004 03:17 AM
what os to select kevinasr Linux - Newbie 2 05-18-2003 07:52 AM


All times are GMT -5. The time now is 06:27 AM.

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