Vim find last occurrence of
An easy way to find the last occurrence is to jump to the end and search backwards:
G?foo<CR>
In fact, there's an even easier way if you were already searching for something. Just jump to the end and search backwards for the thing you were just searching for:
GN
Simple as that.
Edit: if your search occurred on the very last line, then GN
would skip over it to the second last occurrence. Using ggN
would solve this problem. (And gg?foo<CR>
for similar reasons.)
A potentially longer solution:
:vim foo % | clast