For me there was was quite a simple solution. I was trying to edit/create a file in a folder that didn't exist. As I was already in the folder I was trying to edit/create a file in.
i.e. pwd folder/file
and was typing
sudo vim folder/file
and rather obviously it was looking for the folder in the folder and failing to save.