Thanks a lot Charles and Tim for providing me the answer. (It really was just the case of missing the \r or \<cr>)
And surely there was no necessity for such complex steps for this particular example, but it was just an "indicative" example of one of the steps I needed for my script. But rest assured I really do need this. Regards, Sibin -----Original Message----- From: Charles E Campbell Jr [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 14, 2007 12:31 AM To: Sibin P. Thomas Cc: [email protected] Subject: Re: search command in visual mode - how to? Sibin P. Thomas wrote: >Hi all, > >I am stuck in one of my scripting attempts! > >The context : >Suppose I want to delete the string "bio" from the following line "The >biosphere is huge" and I want to do it in this way -> >/bios<CR> >v<CR> >//e<CR> >d<CR> > >Now I want to do the same thing, but conditionally...basically I want to use >the :if construct. >I tried -> :if (@0=~"something") | exe "/bios" | exe "normal v" | exe "//e" | >endif >This where I am stuck; I am not able to reproduce the effect of //e<CR> >through the :if construct. > >In this case I get the error "e481: No range allowed" and if I try -> exe >"normal //e" it just stays in visual mode doing nothing. > >Can anyone help me out here? This is going to play a huge part in most of my >scripts! > > Several notes.... 1. exe "/bios" might fail. You probably should use the search() function: if search('bios') ... endif 2. "bios" might be part of a word (example: symbiosis) and get found when you don't want it to be. Perhaps search('\<bios') would be better? 3. Why not do the search & substitute directly from ex? /\<bios/s/// 4. If for some odd reason you feel you absolutely must use visual mode for this, then try exe "norm! v//e\<cr>d" Regards, Chip Campbell DISCLAIMER: This message (including attachment if any) is confidential and may be privileged. Before opening attachments please check them for viruses and defects. MindTree Consulting Limited (MindTree) will not be responsible for any viruses or defects or any forwarded attachments emanating either from within MindTree or outside. If you have received this message by mistake please notify the sender by return e-mail and delete this message from your system. Any unauthorized use or dissemination of this message in whole or in part is strictly prohibited. Please note that e-mails are susceptible to change and MindTree shall not be liable for any improper, untimely or incomplete transmission.
