Wikia

Vim Tips Wiki

Search multiple buffers for next match

Talk0
1,612pages on
this wiki
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

CommentsEdit

 TO DO 
It has been suggested that this tip should be deleted, mainly because it doesn't function totally satisfactorily, and the script mentioned below is superior.

The decision was to keep the tip for now, and to think about it again. Please add any comments here (or just improve the tip). Let's think again whether to delete it in August 2008. --JohnBeckett 12:46, 22 April 2008 (UTC)


script#1062 does the same thing but better.


Around Wikia's network

Random Wiki