10

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. – Sato Katsura Jul 1 '16 at 6:34
14

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
  • Updated to remove silent! since it was causing the status line to not update when wrapping. – Tommy A Jul 1 '16 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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