On Tue, May 19, 2009 at 11:06 PM, Christian Brabandt <[email protected]> wrote: > > Hi marco! > > On Di, 19 Mai 2009, marco restelli wrote: > >> >> Hi all, >> I would like to write a small function in Vim but I am not sure >> where to start from. Generally speaking, given a pattern and a file >> name, I would like to grep the pattern in the file and put all the >> matching lines into a variable (or a register). Also, the file name >> should be an argument of the function. > > fu! Vimgrep(filename, pattern) > exe "vimgrep /".a:pattern."/j ".a:filename > > for i in getqflist() > echo "found pattern ". i.text ." in ". bufname(i.bufnr) > endfor > endfu >
Christian, Tom, yes, this does exactly what I wanted, thank you! Marco --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
