:s/pattern/replacement operates on the first match and:s/pattern/replacement/g on all.How to operate only on the last one?
Can I make :s operate only on the last match of the line?
substitute
I would use \zs:%s/.*\zspattern/replacement/A little bit of explanation:. represents any single character* represents greedy matching (as many as possible)In Vim you can use zero-width anchors \zs and \ze to define the start and the end of the searched pattern, which you wish to match. Anything before \zs and after \ze in your pattern will remain unaffected by replacement.To make it easy to understand, I would like to use this example from wikia's Search and replace:Save typing by using \zs and \ze to set the start and end of a  pattern. For example, instead of::s/Copyright 2007 All Rights Reserved/Copyright 2008 All Rights Reserved/ Use::s/Copyright \zs2007\ze All Rights Reserved/2008/For more information, look at:h \zs:h pattern-overview