Sunday, December 27, 2009

Re: start search at current line, wrap around?



Ben Fritz wrote:
 On Dec 26, 12:33 pm, Bee <200...@calcentral.com> wrote:   
:.,$s/search/replace/gc  Will start searching at the current line, but continue only to the end of file.  How to wrap the search back around to the current line?  I know the following starts at the beginning of the file and seaches thru to the end of file.  :%s/search/replace/gc     
 Ex commands (like :s) work on ranges, starting from the first line in the range and going to the last line, with the first line required to be no lower in the file than the last. In short, you cannot start at one line and finish above it using a single Ex command.  You could, however, run your .,$ search, then use command-line history (by pressing the <Up> key on the command-line) to recall your command and edit the range as desired to get the first line to the current line
I am not sure that this is what you meant, but
I would like to perform multiple substitutions for the same range,
but not that I know of ahead of times

example

 <table>
 <tr><td> xxx
<tr><td> yyy
</table>

with cursor on the <table>
:.,/\/table/-1 s /td>/td align=center>

This leaves cursor at the /table

Now I want to add valign=top across the same range (not the next table!)


No comments: