On Thu, 2008-10-09 at 10:03 +0100, A. S. Budden wrote:
> Dear all,
> 
> Is there any way to save an error list that has been generated with a
> lot of calls to :vimgrepadd?  I've built up a list of lines of source
> that I will need to reference later and would prefer to not have to go
> through the rigmarole again.
> 
> In the quickfix.txt help, it includes the comment (somewhat out of context):
> 
> "you could write the contents of the quickfix window to a file and use
> ":cfile" to have it parsed and used as the new error list."
> 
> In order to do this, I tried using ":w myquickfixfile.vim", starting a
> new gVim and running ":cfile myquickfixfile.vim", ":copen".  The
> quickfix lists opens and all the lines appear, but they're not
> recognised as error lines (no syntax colouring) and if you press enter
> on one of the lines, the source doesn't jump to that line (although
> the line is then highlighted in yellow).
> 
> Can anyone suggest what I might be doing wrong?
> 
> Many thanks,
> 
> Al

Why not save the output of string(getqflist()) to a file? I use this
approach frequently myself. The only problem is that some items in the
list returned by getqflist() will include buffer numbers which become
invalid once Vim is closed, but that's easily fixed. You can use the
following functions to save and restore your quick-fix list:

function SaveQuickFixList(fname)
 let list = getqflist()
 for i in range(len(list))
  if has_key(list[i], 'bufnr')
   let list[i].filename = fnamemodify(bufname(list[i].bufnr), ':p')
   unlet list[i].bufnr
  endif
 endfor
 let string = string(list)
 let lines = split(string, "\n")
 call writefile(lines, a:fname)
endfunction

function LoadQuickFixList(fname)
 let lines = readfile(a:fname)
 let string = join(lines, "\n")
 call setqflist(eval(string))
endfunction

Hope this helps,

Peter


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

Reply via email to