Vim Tips Wiki
Register
Advertisement



Tip 950 Printable Monobook Previous Next

created June 15, 2005 · complexity basic · author Bill Weir · version 5.7


When editing multiple files I like to have a search operation that behaves a bit like "/*" in less (to search multiple buffers looking for the next match). The Nextmatch function (below) does this, although it doesn't behave quite as I would like.

function! Nextmatch()
  let v:errmsg = "X"
  let s:x = bufnr("%")
  while v:errmsg != ""
    bnext
    if bufnr("%") == s:x
      break
    endif
    1
    let v:errmsg = ""
    silent! /
  endwhile
endfunction

Comments


Advertisement