LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-16-2012, 10:46 AM   #1
travix
LQ Newbie
 
Registered: Jul 2012
Posts: 11

Rep: Reputation: Disabled
vi editor- regular expressions


is it possible to tell vi to look for a the nth occurrence of a pattern in a single line? All the info and tutorials I've been reading only reference patterns as they occur in multiple lines.

Or can you tell it to identify a certain sequence on a line and then tell it to look for the nth occurrence of a different sequence after identifying the first (the first being a sort of marker)? Like, once you see this pattern occur once look for the fifth occurrence of this other pattern, all on the same line.
 
Old 09-16-2012, 11:00 AM   #2
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836
Blog Entries: 1

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
Not sure if that is what you're after but that's what I'd do:

1.Make sure the cursor is on the said line and you are in the command mode.
2. Type a given number, eg. 4 and then /pattern (it will highlight the 4th occurrence of the pattern on that particular line.)
3. When you press Enter, all other occurrences will get highlighted as well but the cursor will be at the 4th one.


HTH
 
Old 09-19-2012, 04:27 PM   #3
travix
LQ Newbie
 
Registered: Jul 2012
Posts: 11

Original Poster
Rep: Reputation: Disabled
regular expressions in vi

Thanks. That'll work for now, but I was hoping for something I could include in the regular expression. I''l keep looking. But that definitely helps. Thank You!
 
Old 09-24-2012, 11:50 PM   #4
sai krupa
LQ Newbie
 
Registered: Sep 2012
Posts: 3

Rep: Reputation: 0
Vi is one of the editor in Linux. It helps to make edit the program which already been saved in the Linux for execution. For making the edit we can write the command as vi filename.c by this we can edit the given filename program. And it helps in both the cases as before and also after the execution.
 
Old 09-25-2012, 06:06 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,349

Rep: Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750
You might(?) be able to do something with vim macros http://vimdoc.sourceforge.net/htmldoc/usr_10.html#10.1
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expressions nova49 Linux - Newbie 4 07-13-2011 07:05 AM
Regular Expressions in Quanta Web Editor Mr T Donegal Linux - General 4 08-16-2010 09:23 AM
Regular expressions Khaj.pandey Linux - Newbie 19 04-21-2010 11:09 PM
Regular Expressions ziggy25 Linux - Newbie 7 11-05-2007 06:57 AM
Regular expressions bhuwan Programming 5 02-25-2006 11:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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