Vim: No write since last change, even though I changed the file [duplicate]

Posted on Jun 5, 2022

Question

I'm trying to set up a file on my ubuntu machine, but when I try to change the contents before saving the file I've just created, vim returns the error: No write since last change.

I've created the file with the user, who is trying to change the contents and sudo vim file.ext doesn't solve the problem eiter.

Basically, my workflow looks like this:

touch file.js

vim file.js In the file:

console.log('Hello_world');

Afterwards, I'm entering :q [Enter] and then the error message appears.

Answer

Try this, after editing your file, quit with this command: wq!. the ! means force the process, and when you combine it with wq that means force to save and quit.