Can’t open file for writing Vim Linux? Check the file path for its existence
The first thing you need to do is checking the directory or the file path in order to be sure that it does exist. If it doesn’t or one of its parent directory doesn’t, trying to open it with Vim will definitely raise “E212: Can’t open file for writing” error.
How do you open a file in write mode in Linux?
More Linux resources.
|$ vi <filename>
|Open or edit a file.
|Switch to Insert mode.
|Switch to Command mode.
|Save and continue editing.
How do I enable writing in Vim?
- Open a new or existing file with vim filename .
- Type i to switch into insert mode so that you can start editing the file.
- Enter or modify the text with your file.
- Once you’re done, press the escape key Esc to get out of insert mode and back to command mode.
- Type :wq to save and exit your file.
How do I open a Vim file in Linux? Launching Vim
In order to launch Vim, open a terminal, and type the command vim . You can also open a file by specifying a name: vim foo. txt .