Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

Has anyone an idea?

Best regards, Lenny

EDIT:

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.

like image 395
Lenny Will Avatar asked May 22 '19 21:05

Lenny Will


People also ask

How do I exit No write since last change?

Type 'q! ' in place of 'q' and press Enter. 'q! '

When in Vim the correct way to write Save changes and quit is?

To save a file in Vim / vi, press Esc key, type :w and hit Enter key. One can save a file and quit vim / Vi by pressing Esc key, type :x and hit Enter key.

How do I save an edited text in Vim?

Press Esc key and type :w to save a file in vim. One can press Esc and type :wq to save changes to a file and exit from vim. Another option is to press :x.


2 Answers

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.

like image 168
Siyavash vaez afshar Avatar answered Oct 12 '22 23:10

Siyavash vaez afshar


The error message     "No write since last change"    that you encounter basically means that
you have not save to your file since the last editing, the write here have the same meaning as save.

If you want to save and then quit VIM, type the following
:wq Enter
or
you can also type the following
:w Enter     <-------- This command is to save the file
:q Enter     <-------- This command quit VIM


If you want to quit without saving any changes, type the following
:q! Enter

like image 39
Jason Avatar answered Oct 12 '22 22:10

Jason