I use VIM 7.4. When I want to search some text in my project, i use following command:

:vimgrep /pattern/j *.c *.h

Then I use :cw command to open quickfix list for getting search results.

Here is my problem. Sometimes quickfix displays something like:

main.c|71 col 5| u8 pattern = 0;

It's okay. But sometimes it displays full path:

Users\user\dir1\dir2\etc\etc\etc\project\main.c|71 col 5| u8 pattern = 0;

And it becomes impossible to use quickfix comfortably because file path "ate" the whole horizontal space.

What can I do to get rid of full paths in quickfix list? What alternatives could you recommend for "in-project" search?

Thank you.


1 Answer 1


You can write a custom quickfixtextfunc to customize the results.
See :help quickfix-window-function for more details. Using the answer to this more involved customization as a guide, you can do the following to set the results to just the text strings:

set quickfixtextfunc=QFTextOnly

func QFTextOnly(info) 
    if a:info.quickfix
        let qfl = getqflist(#{id: a:info.id, items: 0}).items
        let qfl = getloclist(a:info.winid, #{id: a:info.id, items: 0}).items
    let l = []
    for idx in range(a:info.start_idx - 1, a:info.end_idx - 1)
        call add(l, substitute(qfl[idx].text, '^\s*','',''))
    return l

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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