Created
January 16, 2016 08:30
-
-
Save chemzqm/b7d1091d5b4b85ebd622 to your computer and use it in GitHub Desktop.
Add Qdo and Qargs command used for replaceAll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" ============================================================================ | |
" Description: Add Qdo and Qargs command used for replaceAll | |
" Author: Qiming Zhao <[email protected]> | |
" Licence: Vim licence | |
" Version: 0.1 | |
" Last Modified: December 31, 2015 | |
" ============================================================================ | |
if exists('did_qdo_loaded') || v:version < 700 | |
finish | |
endif | |
let did_qdo_loaded = 1 | |
function! s:Qdo(bang, command) | |
execute 'UniteClose' | |
if exists('w:quickfix_title') | |
let in_quickfix_window = 1 | |
cclose | |
else | |
let in_quickfix_window = 0 | |
endif | |
arglocal | |
exe 'args '.s:QuickfixFilenames() | |
exe 'argdo'.a:bang.' '.a:command | |
argglobal | |
if in_quickfix_window | |
copen | |
endif | |
endfunction | |
function! s: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(map(values(buffer_numbers), 'fnameescape(v:val)')) | |
endfunction | |
command! -nargs=1 -bang Qdo call s:Qdo(<q-bang>, <q-args>) | |
command! -nargs=0 -bar Qargs execute 'args' s:QuickfixFilenames() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment