LinuxQuestions.org
Register a domain and help support LQ
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 10-28-2009, 08:27 PM   #1
mortonmorton
Member
 
Registered: Sep 2009
Posts: 36

Rep: Reputation: 16
VI question on copy paste


Hi,
How do you find the last occurence of a character/string in a line? I ask because I was trying to edit this line:

Code:
BACKGROUND_DUMP_DEST=/u01/app/oracle/admin/ORA9IR2/bdump
So I want to copy only from the first '/' up to the last '/' before 'bdump'. Right now I only do 'y$' then I just edit the last word. Is this possible? Thanks.
 
Old 10-28-2009, 08:44 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Well, a basic search fwd is '/' key (ie /<pattern>), but searching for a '/' require a '\' esc ie

/\/

will find first occurrence of '/', measured from the current cursor position(!). The search backwards key is '?'. Note that vi search remembers the last pattern used, so you don't have to repeat the pattern.
'n' repeats the search for next occurrence, in the direction last specified.

However, sounds like you're looking for a search/copy/reuse ? Personally, I'm nearly always in an xterm, so I use the mouse copy/paste, it's easier.
Can you show an example of what you are trying to do?
 
Old 10-28-2009, 08:51 PM   #3
mortonmorton
Member
 
Registered: Sep 2009
Posts: 36

Original Poster
Rep: Reputation: 16
Basically sometimes I have several key=value configs, where the value has some repeating strings like on this one the path before the final directory. So I have some

DEST_1=/root/path/mainfolder
DEST_2=/root/path/mainfolder2

I just thought there might be something like 'y<up to last occurence of this character on this line>' command =) Although I could also just copy first the path to the folder without the 'last folder'.

Tested the combination of 'y' and 'm', which I mean: marking your starting position, go to last position ( plus one character ) then 'y' then go back to starting position ( marked position ) . Lot of keyinputs to me =(

Last edited by mortonmorton; 10-28-2009 at 09:03 PM.
 
  


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
Copy and paste posix_memalign Linux - Software 14 07-05-2009 01:06 PM
A simple question on copy and paste satimis Fedora 4 06-02-2006 07:13 AM
a windows question..copy&paste.. desperate.. doublefailure General 3 08-15-2004 06:49 PM
xpdf - copy and paste question satimis Linux - Software 4 05-09-2004 11:47 AM
how to copy and paste acd copy cd paschim Linux - General 2 04-05-2004 10:25 AM


All times are GMT -5. The time now is 04:36 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