Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

how can I lop through buffers in quickfix list :copen and make some actions with it.

Or any alternative way to put those files to args list and I can use argsdo.

share|improve this question

2 Answers 2

You can write the loop yourself:

for file in ['foo.txt', 'bar.txt']
   execute 'edit' fnameescape(file)
   " Your processing here.
endfor

Or if you already have all files loaded in Vim, use :bufdo and execute your commands conditionally, based on whether the buffer (or buffer number with bufnr('')) is in your list:

bufdo if index(['foo.txt', 'bar.txt'], bufname('')) != -1) | execute ... | endif

Edit: Now that I understand you want to iterate over the files in the quickfix list (the one you see when you do :copen, you can get their buffer numbers via map(getqflist(), 'v:val.bufnr'). Still need to avoid processing the same buffer multiple times, though.

share|improve this answer
    
This is actually not what I'm looking for. I don't know exactly what files I'm gonna edit, I just want it take the files listed in :cope. So it will be not efficient that everytime we get files in vim cope and then remember the name and then write function to do it. Sometimes, it's just a replacement –  nXqd May 2 '13 at 9:53
    
@Vdt I didn't get that part initially; please use the available markup (like you did in your comment), and beware of typos in your question. –  Ingo Karkat May 2 '13 at 10:06
    
Thanks for the suggestion :) –  nXqd May 3 '13 at 6:38
up vote 0 down vote accepted

I've found a vim plugin that suits my need completely which is vim-qargs. The idea behind is almost the same with @Ingo.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.