What happens is sometimes when we try to ssh into a system and open gedit in that machine(remote) everything seems fine until we try to type something or save into that file or even we cannot open other files using open menu in file tab.
So the solution here is:
Use nautilus/gedit on local machine
1. Open a nautilus file browser window and select “connect to server” from the menu in the top panel.
2. Enter in the server(remote) info (use ssh:// or sftp:// for ssh connections).
3. Enter password and there you go. You will be connected to the remote machine and now your gedit works fine.
Courtesy: this answer from ask ubuntu is where I found the solution.