Search and Replace over multiple files - quickfixdo

57 views
Skip to first unread message

Asis Hallab

unread,
Dec 5, 2010, 4:28:57 AM12/5/10
to vim...@googlegroups.com
Hello everyone, Hello Christian!

I tried something new with the script Christian Brabandt provided in order to do something like
argdo with the entries of the quickfix, repective the location-list.

I tried
:vimgrep foo app/**/*rb
:Qfdo %s/foo/bar/gc | update

Unfortunately vim tells me
Not an editor-command: update.

Does anyone have an idea why that error occurs?
And why does it work with argdo and not with Qfdo?

The function and the command are defined as follows,
- thanks to Christian Brabandt:
fun! QFDo(bang, command)
     let qflist={}
     if a:bang
         let tlist=map(getloclist(0), 'get(v:val, ''bufnr'')')
     else
         let tlist=map(getqflist(), 'get(v:val, ''bufnr'')')
     endif
     if empty(tlist)
        echomsg "Empty Quickfixlist. Aborting"
        return
     endif
     for nr in tlist
     let item=fnameescape(bufname(nr))
     if !get(qflist, item,0)
         let qflist[item]=1
     endif
     endfor
     :exe 'argl ' .join(keys(qflist))
     :exe 'argdo ' . a:command
endfunc

com! -nargs=1 -bang Qfdo :call QFDo(<bang>0,<q-args>)


--
Asis Hallab

Christian Brabandt

unread,
Dec 6, 2010, 5:00:37 AM12/6/10
to vim...@googlegroups.com
On Sun, December 5, 2010 10:28 am, Asis Hallab wrote:
> I tried
> :vimgrep foo app/**/*rb
> :Qfdo %s/foo/bar/gc | update
> com! -nargs=1 -bang Qfdo :call QFDo(<bang>0,<q-args>)

Try, if adding the -bar attribute to the com! definition helps.

regards,
Christian

Asis Hallab

unread,
Dec 6, 2010, 11:05:31 AM12/6/10
to vim...@googlegroups.com
Hello Christian,


thank you very much for your help.
You suggestion works perfectly fine.

Have a nice "Sankt Nikolaus"-Day!
Asis

2010/12/6 Christian Brabandt <cbl...@256bit.org>

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php



--
Asis Hallab
Rothehausstr. 6 - 12
50823 Köln

Skype: asis.hallab.cgn
Fest (Köln) 42346046
Mobil  (O2) 0176 63370211
Fax 01212 - 5 - 30697106
Reply all
Reply to author
Forward
0 new messages