In classic editor, I can write html in the text tab of the editor. But in Gutenberg editor, it seems I can only edit a block in HTML(using the block option "Edit as HTML"). Is there a way to edit the whole post as HTML?
You can switch between the Code editor and Visual editor for the whole post/page via the shortcut: Ctrl + Shift + Alt + M
. The Code editor enables direct editing of the underlying HTML.
The menu option is also found underneath 'Options' in the top right hand corner of the Edit Post view:
Be careful when editing inner Gutenberg Block HTML code directly as it can potentially introduce validation errors. Use post revisions to return to the previously valid HTML if you encounter issues and need to go back.