只需一个函数即可触发 QuickFixCmdPost
Trigger QuickFixCmdPost just with one function
考虑以下最小 vimrc:
set nocompatible
function! OpenBuffer()
execute "silent botright 2new empty_buffer"
call append(line('$'), "This should only show up when running GrepFixme()")
normal dd
endfunction
function! GrepTodo()
execute "vimgrep/TODO/j %"
endfunction
function! GrepFixme()
execute "vimgrep/FIXME/j %"
endfunction
augroup test_au
au!
au QuickFixCmdPost vimgrep call OpenBuffer()
augroup END
" TODO: foo
" FIXME: bar
正如在 GIF 中看到的那样,QuickFixCmdPost
自动命令被触发
当我调用 GrepFixme()
或 GrepTodo()
函数时。我想要
仅当我调用 GrepFixme()
时触发 QuickFixCmdPost
自动命令
函数,而不是当我调用 GrepTodo()
函数时。有没有办法
实现那个?
您可以使用 :noautocmd
或设置 'eventignore'
来阻止 autocmd 启动。示例:
:noautocmd vimgrep/foo/
如需更多帮助,请参阅:
:h :noa
:h 'eventingore'
考虑以下最小 vimrc:
set nocompatible
function! OpenBuffer()
execute "silent botright 2new empty_buffer"
call append(line('$'), "This should only show up when running GrepFixme()")
normal dd
endfunction
function! GrepTodo()
execute "vimgrep/TODO/j %"
endfunction
function! GrepFixme()
execute "vimgrep/FIXME/j %"
endfunction
augroup test_au
au!
au QuickFixCmdPost vimgrep call OpenBuffer()
augroup END
" TODO: foo
" FIXME: bar
正如在 GIF 中看到的那样,QuickFixCmdPost
自动命令被触发
当我调用 GrepFixme()
或 GrepTodo()
函数时。我想要
仅当我调用 GrepFixme()
时触发 QuickFixCmdPost
自动命令
函数,而不是当我调用 GrepTodo()
函数时。有没有办法
实现那个?
您可以使用 :noautocmd
或设置 'eventignore'
来阻止 autocmd 启动。示例:
:noautocmd vimgrep/foo/
如需更多帮助,请参阅:
:h :noa
:h 'eventingore'