Is there a flag for :s[ubstitute] in Vim that will not save the pattern?

Viewed 113

I'm trying to create an autocmd that will replace all the whitespaces in the file when I exit the insert mode. However, AFAIK that would make Vim remember the pattern and remove what was already in there.

" Add function for remove tailing whitespaces
command! CleanupTrailingSpaces :%s/\s\+$//ge | :nohlsearch
autocmd InsertLeave * :CleanupTrailingSpaces

Is there a flag for :s[ubstitute] that will make it not saving the pattern?

2 Answers
Related