I am trying to edit sources.list using vi editor but getting the following error while saving the file:
/etc/apt/sources.list\" E212: Can\'t open file for wr
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.