LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   vi editor- regular expressions (https://www.linuxquestions.org/questions/linux-general-1/vi-editor-regular-expressions-4175427517/)

travix 09-16-2012 10:46 AM

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.

sycamorex 09-16-2012 11:00 AM

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

travix 09-19-2012 04:27 PM

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!

sai krupa 09-24-2012 11:50 PM

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.

chrism01 09-25-2012 06:06 AM

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


All times are GMT -5. The time now is 06:19 PM.