I was watching a tutorial in which instructor using vim for ruby on rials development. He writes code on blank screen and then uses command :w hello.rb the whole code behaves like ruby code... when i try to use this command it gives an error message. I searched a lot on stackoverflow.com There are some similar questions but no one works... http://vim.wikia.com/wiki/Saving_a_file and Vim Can't Save File (E212) and one solutions is :w!! but i want to save file as :w filename e.g :w hello.rb
Asked
Active
Viewed 294 times
-2
-
1“it gives an error message”—what error message it gives? – Aleksei Matiushkin Jul 02 '15 at 08:35
-
What is ruby on rials? – sawa Jul 02 '15 at 09:39
-
what is the reason of vote down? it is just a question? – Rana Zubair Jul 02 '15 at 14:16
-
Down vote is because there are plenty of ways that saving a file can fail. You said "gives an error message" without saying what the error message was. Without the specific error, nobody can tell you why writing the file failed. So here's another downvote... – Ben Jul 02 '15 at 21:36
1 Answers
1
Try using the following (after pressing escape) :wq! Should work.

Joe
- 2,386
- 1
- 22
- 33
-
-
vi hello.rb will either edit the existing file or create a new one. Then :wq! To save and quit. Simple :) – Joe Jul 02 '15 at 08:35
-
If your error message is due to permissions, try: sudo vi hello.rb instead of vi hello.rb – Joe Jul 02 '15 at 08:36