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

regards,
Christian
-- 
hundred-and-one symptoms of being an internet addict:
238. You think faxes are old-fashioned.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to