13

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?

lwassink
  • 281
  • 1
  • 7

1 Answers1

21

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
Tommy A
  • 6,770
  • 22
  • 36