Question

How can I circumvent the errors, such as E212 and E13, in the commands?

:'a,'bw set_question_tags.php
:'a,'bw >> set_question_tags.php

In some cases, even with Pavel's command:

"create_a_file_and_save.php" E212: Can't open file for writing
Was it helpful?

Solution 2

The question consisted of two parts, the exclamation mark solved some problems but some needed sudo rights. Since I have changed my system, I cannot verify things anymore. I will here however answer the question because now it seems clear to me.

1. E212 problem solved

:'a,'bw! !sudo tee save_to_new_file_with_different_user.php

:'a,'bw! !sudo tee -a append_to_a_file_with_different_user.php

2. For E13 problem, please, see Pavel Shved's answer.

This answer does not address the sudo part in my inital question that is How can I circumvent the errors, such as E212 and E13, in the commands? When I found it, I had to change the acceptance of the question because it did not address it, only a part.

3. About Sudo problem

The saver clearly had no permission to some files because s/he was unable to save without sudo and not solved just by ! -mark. Either the file was made by sudo or the another user had not shared the file to saver, the reason for E212 from manuals:

                                                   *E190* *E212*  

Cannot open "{filename}" for writing Can't open file for writing

For some reason the file you are writing to cannot be created or overwritten. The reason could be that you do not have permission to write in the directory or the file name is not valid.

The E13 problem had nothing do with E212 error, from Vim's manuals:

                                                    *E13* *E189*  

File exists > (add ! to override) "{filename}" exists (add ! to override)

You are protected from accidentally overwriting a file. When you want to write anyway, use the same command, but add a "!" just after the command. Example: > :w /tmp/test changes to: > :w! /tmp/test

OTHER TIPS

(Sorry, since the OP completely changed his question, my answer stopped making sense)

So, you basically need a command that appends text to the file even if it doesn't exist? Try using exclamation mark:

:'a,'bw! set_question_tags.php
:'a,'bw!>> set_question_tags.php
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top