Tip 679 Printable Monobook Previous Next
created March 16, 2004 · complexity basic · author Anon · version 5.7
To find the last occurrence of an item, put the following in your vimrc file.
com! -nargs=1 Findlast :execute'normal G<cr>' | :execute':normal ?' . <arg> . '?<cr>'
Usage:
:Findlast item " For example: :Findlast 123
With a regular expression, put the regex inside single quotes, for example:
:Findlast '\d\d\d'
Explanation:
G = Goto line [count], default last line, on the first non-blank character (linewise)
? = Search backward for the [count]'th previous occurrence of {pattern} (exclusive)
. = string concatenation