Q:

Return to last cursor in VIM after indenting

I use gg=G to auto-format the whole file in VIM. After the whole file is indented, the cursor is returned to the begining of the file.
How can I do so that VIM returns the cursor to the last position? Say I called the command in the line 45, I want VIM to return me to this line after indenting the file.
Edit: if anyone is interested, I did add the following command to my .vimrc
" Autoformat document                                                                                                                     
nnoremap F gg=G''

So by using Shit+f I can now reformat the whole document and stay at the same cursor.

A:

As stated by /u/nemo157, in an answer comment in How do I fix the indentation of an entire file in Vi?, issueing '' returns you to your last position. As per vim docs:
                            *''* *``*
''  ``      To the position before the latest jump, or where the
            last "m'" or "m`" command was given.  Not set when the
            |:keepjumps| command modifier was used.
            Also see |restore-position|.

So if you do gg=G'' you're back where you started.

