On Thursday, April 12, 2012 4:24:08 AM UTC-5, gaoqiang wrote:
> I want to search a word in multi tabs, but :tabdo just search all the
> tabs and it doesn't stop when hit the word,which just seems useless..
> any advice ?

Use :vimgrep.

Unfortunately you'll need to do some scripting if you want to automatically 
only search the files open in your current tabs. The tabpagebuflist() function 
should be useful. You could do something like this inside a function:

let curtab=1
let allfiles_in_tabs = ""
while curtab <= tabpagenr('$')
  let allfiles_in_tabs .= join(map(tabpagebuflist(curtab), "bufname(v:val)"))
  let curtab+=1
endwhile

Then use an :exec command to use :vimgrep on the resulting file list. Put in a 
user-defined command for easy use.

Note that this will not work on any unsaved files or buffers which don't 
contain a real file.

Why are you trying to search a word in multiple tab pages? Maybe there's a 
better way to do what you're trying to accomplish.

With built-in commands, you could also use something like:

:tabdo windo s/wordToFind/\0/gc

which will perform a "replace every occurrence of wordToFind with itself in 
every window of every tab and confirm before replacing". This should allow you 
to see each match as you go.

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