title: Vim open a file found through grep
body: <p>So I'm browsing a file in vim. I realize the function I am looking for is another file. So I do  <code>:! ack-grep "function tracking" ../</code> to look for it, and I see I need to examine file "../../tracking/api/ etc etc" some really long file name. what I'm doing now is trying to remember this file, type <code>fg</code> to get back into vim, and then :e "that really long file name". I'm wondering if there's an easier way to do this?</p>
  
  <p>For instance, can I do something like <code>vim -addtab &lt;some file&gt;</code> from the command line once I've used ack-grep to find what I'm looking for, and then when I do <code>fg</code> to get back to vim, the file will be open in one a tab?</p>
  
  <p>Awesome, lots of suggestions. I'll try them all out and in comments as I do. Then I'll pick what worked best for me once I've tried them all.</p>
  
  <p>So this is the function that I settled on:</p>
  
  <pre><code>function! s:NewTabGrep(...)
    let args=split(a:1)
    if len(args) == 2
        let dir=args[1]
    else
        let dir='.'
    endif
    echom args[0] . "  " . shellescape(dir)
    tabnew | execute "r ! ack-grep ". shellescape(args[0]) ." ". shellescape(dir) 
  endfunction
  com! -nargs=? GrepTab call s:NewTabGrep('&lt;args&gt;')
  </code></pre>
  
  <p>This performs the search, and opens the results in a new vim tab. Then I can use CtrlP to open whichever file seems most interesting. Thanks to Merlin2011 for inspiration.</p>