Easily switch between source mode <-> live preview <-> preview

I put the code as templater script. Then only one line of code is needed to call this function on any template, at start. Thanks a lot. My default mode is reading view and it was impossible to insert template in existing note if not previously switched to edit mode. I’m surprise this option or function is not native in templater.