LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-23-2015, 02:29 AM   #1
techie_san778
Member
 
Registered: Jul 2011
Posts: 90

Rep: Reputation: Disabled
Exclamation How a select a portion of a line using Visual mode ?


Hello Friends,

I have a problem in selecting a portion of a line
using Visual Mode in VI editor.

Let's say i have the following text :

Once upon a time there was a king
in the far lands of Africa..


Now i want to select "there was a king" using Visual Mode. How to select, copy and paste in the desired position ?
If it is not possible in Visual mode but possible in any other mode, please suggest me.

Thanks..
 
Old 08-23-2015, 02:42 AM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,193
Blog Entries: 24

Rep: Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159
Do it in command mode...

1. Place cursor over the first letter you want to copy
2. Tap the "v" key, then move cursor to last letter you want to copy
3. Tap "y" key
4. Move cursor to the place where you want to paste it, tap "p" key
 
1 members found this post helpful.
Old 08-23-2015, 02:47 AM   #3
techie_san778
Member
 
Registered: Jul 2011
Posts: 90

Original Poster
Rep: Reputation: Disabled
Thanks astrogeek, your suggestion worked.. What if i had to select multiple (group of) lines,
(say line 32 to 34) ?
 
Old 08-23-2015, 02:59 AM   #4
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,193
Blog Entries: 24

Rep: Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159
You are welcome!

Easiest way is same as before - place cursor at first of first line, tap "v", move cursor down to end of last line, tap "y", then position and tap "p" to paste.

You could also select by line number

Code:
:32,34y

then new position and...

p
You probably have a built-in tutorial for Vim on most distros that will cover these basic moves and many more. Type vimtutor from a shell prompt, it is a really good introduction to vim.

Last edited by astrogeek; 08-23-2015 at 03:06 AM.
 
1 members found this post helpful.
Old 08-25-2015, 05:39 AM   #5
techie_san778
Member
 
Registered: Jul 2011
Posts: 90

Original Poster
Rep: Reputation: Disabled
Thanks astrogeek again for your valuable reply..
 
  


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] How to select more than 1 line,copy those selected more than one line,and paste them. shabariv Linux - Newbie 1 02-02-2015 11:51 AM
HOW TO cut an arbitrary portion of an mp3 file on command line wheeliee Linux - General 2 05-07-2010 08:20 AM
Visual mode of VIM jcky Linux - Newbie 2 01-03-2010 04:18 AM
selecting only the required portion of string in a line raghu123 Programming 4 09-17-2008 02:19 AM
shell script - matching portion of the line alenD Programming 11 10-02-2007 10:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:51 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
Open Source Consulting | Domain Registration