Gary Johnson wrote:
On 2010-03-10, pixelterra wrote:
seems some variation of :vimgrep may work, but i found the docs
cryptic.

I thought that a refinement of

    :try | normal n | catch | n | endtry

with 'nowrapscan' set might work, but even that much didn't work for
me.  I just got the error messages

    Error detected while processing :
    E385: search hit BOTTOM without match for: who

and the 'catch' clause was never executed.

did you try

  exec 'normal n'

instead of

  normal n

which eats the rest of your line, and if mapping, using "<bar>" instead of "|"?

Just cleaning up your example...I too got the uncatchable E385 whether issued directly or <bar>'ed and issued as a mapping. However, if I wrapped it in a function, it seemed to work:

  function! SearchWrap()
    try
      normal n
    catch
      n
    endtry
  endfunction
  nnoremap <f4> :call SearchWrap()<cr>

seemed to do the trick for me with 'nowrapscan' set. I'm not sure why the E385 refuses to be caught by an in-line (<bar>'ed) try/catch/endtry block. I even tried wrapping the "n" in an exec, in case it was choking on the bar as a parameter.

Andy's reply just came in:

@Gary: a try block cannot catch Beeps from a Normal mode
command.

but I'm not sure (1) where this is documented, and (2) why Gary and I were getting the E385 (an error, not just a beep) and it still wasn't being caught inline vs. in my function.

Seeing Andy's solution, I like it better, but I'm still left scratching my head a bit on try/except issues.

-tim


--
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

Reply via email to