Permalink
Browse files

Add quickfix to arglist functions/commands.

  • Loading branch information...
1 parent 529cd6f commit e924edf4c166f93207e21add25a6df5c9f9b0498 @nelstrom committed Feb 13, 2011
Showing with 37 additions and 0 deletions.
  1. +37 −0 vimrc
View
37 vimrc
@@ -213,6 +213,43 @@ if has("autocmd")
endif
" Custom commands and functions {{{1
+" Create a :Quickfixdo command, to match :argdo/bufdo/windo
+" Define a command to make it easier to use
+command! -nargs=* Qargs call QuickfixFilenames()
+function! QuickfixFilenames()
+ " Building a hash ensures we get each buffer only once
+ let buffer_numbers = {}
+ for quickfix_item in getqflist()
+ let buffer_numbers[quickfix_item['bufnr']] = bufname(quickfix_item['bufnr'])
+ endfor
+ return join(values(buffer_numbers))
+endfunction
+
+command! -nargs=+ QFDo call QFDo(<q-args>)
+" Function that does the work
+function! QFDo(command)
+ " Create a dictionary so that we can get the list of buffers rather than
+ " the list of lines in buffers (easy way to get unique entries)
+ let buffer_numbers = {}
+ " For each entry, use the buffer number as a dictionary key (won't get
+ " repeats)
+ for fixlist_entry in getqflist()
+ let buffer_numbers[fixlist_entry['bufnr']] = 1
+ endfor
+ " Make it into a list as it seems cleaner
+ let buffer_number_list = keys(buffer_numbers)
+
+ " For each buffer
+ for num in buffer_number_list
+ " Select the buffer
+ exe 'buffer' num
+ " Run the command that's passed as an argument
+ exe a:command
+ " Save if necessary
+ update
+ endfor
+endfunction
+" http://stackoverflow.com/questions/4792561/how-to-do-search-replace-with-ack-in-vim
" Show syntax highlighting groups for word under cursor {{{2
" Tip: http://stackoverflow.com/questions/1467438/find-out-to-which-highlight-group-a-particular-keyword-symbol-belongs-in-vim
nmap <C-S-P> :call <SID>SynStack()<CR>

0 comments on commit e924edf

Please sign in to comment.