If I run :cnext when I'm already at the end of the quickfix list I get the error message

E553: No more items

and nothing happens. Instead of this, when I enter :cnext at the end of the list, I would like vim to cycle back around to the first quickfix entry. Is it possible configure vim for this behavior?

  • 1
    Already answered many times in the past. Here's one example. Commented Jul 1, 2016 at 6:34

1 Answer 1


You can write some commands:

command! Cnext try | cnext | catch | cfirst | catch | endtry
command! Cprev try | cprev | catch | clast | catch | endtry

command! Lnext try | lnext | catch | lfirst | catch | endtry
command! Lprev try | lprev | catch | llast | catch | endtry

If the exception is caught, it jumps to the first/last item. You can use cabbrev so you don't have to use the upper case commands:

cabbrev cnext Cnext
cabbrev cprev CPrev
cabbrev lnext Lnext
cabbrev lprev Lprev

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.