Searching from end of file using VIM
https://stackoverflow.com/questions/12867573/searching-from-end-of-file-using-vim
Searching from end of file using VIM
Ask Question Asked 9 years, 8 months ago Modified 3 years, 11 months ago Viewed 64k timesHow do I search from the end of file using VIM? I want to search for the last occurrence of XXXX in the open file.
vim se-share-sheet#willShow s-popover:shown->se-share-sheet#didShow">Share Improve this question edited Jun 7, 2013 at 11:49My suggestion is to use a range combined with searching backwards via ?.
:1?XXXX
Overview:
1?XXXXis the range.- The
1means first line of the file. ?XXXXmeans search backwards from the first line (wrapping around) until you find the patternXXXX
As ZyX mentioned this relies on wrapscan to be set, which it is by default. See :h 'wrapscan' for more information.