The API command view.replace always adds to the undo stack. However, it is useful for certain plugins to do a replace without actually adding to the undo stack. This will primarily be useful for collaborative editing plugins, where usually the other person's changes need to be replicated in your view, but each person keeps a separate undo stack (like in Google Docs).