On 2010-04-20, Unwen wrote:
> Hi,
> I'd like to know if there's a way to negate/invert the result of a
> search function call that I use as a condition in a while loop.
> I could negate the regexp but as this is always a bit clumsy I
> wondered if there's another way, a "while not" or something else.

The search() function call returns a line number or zero if no match
is found, so I'm not sure what result you want to negate or invert.
Perhaps your while condition could be something like one of these.

    while search(...) == 0
    while search(...) != 0
    while !(search(...) == 0)

> Alternatively, is there another way to check for the existence of a
> certain string within the current line?

For searching the current line you could test some condition like
one of these.

    getline(".") =~ 'your string'
    getline(".") !~ 'your string'
    match(getline("."), 'your string') != 0

Take a look at

    :help getline()
    :help expr4
    :help expr7
    :help match()
    :help matchstr()

HTH,
Gary

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en

Reply via email to