32

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.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Lenny Will
  • 549
  • 1
  • 4
  • 11
  • In order to create a [minimum example](https://stackoverflow.com/help/mcve) of the problem, please include the commands you are trying to use. From your question, it appears you have a misunderstanding of what the commands you are using actually do – jeremysprofile May 22 '19 at 21:48
  • @jeremysprofile Editing the question to provide more information – Lenny Will May 23 '19 at 06:49
  • `but when I try to change the contents before saving the file I've just created, vim returns the error` -> `:q` is not saving! `:w` writes a file and `:wq` writes and exits. `:h :w` for more info. – Harish May 23 '19 at 06:53

2 Answers2

58

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.

Siyavash vaez afshar
  • 1,303
  • 10
  • 12
40

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

Community
  • 1
  • 1
Jason
  • 531
  • 3
  • 7