Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim won't write file without a "!" sometimes (E13)

Tags:

vim

Very often (as in multiple times an hour), when I save my file :w, vim tells me "E13: File exists (add ! to override)"

Example

I don't know why it does this, I can't reliably reproduce it, it feels random.

This is my vimrc, note that it sets nobackup, nowritebackup, and noswapfile, and there is a function to strip trailing whitespace that gets run when I save a file.

Also, I tend to have 20 vims open at once, all backgrounded, often editing the same file. Also not improbable that I have the same buffer open in multiple windows (ie :vsp) and might open it, then reopen it with the e command a lot, possibly from a relative filepath, or possibly from an absolute one (the cmap %/ <C-R>=expand("%:p:h")."/"<CR>). No idea if any of this matters. Next time I have this issue, I'll check my ls and report anything odd.

Update:

When I tried to save "lib/seeing_is_believing/wrap_expressions.rb" (note that this is a different file than the one in the gif), this happened again. Here is the ss, it's buffer 3:

ls

Update2 (for @mMontu)

I just realized that there are two errors happening here. The one in the screenshot is the readonly thing. The one in the gif is the more common one, E13: File exists (add ! to override)

The one I just hit is E13 File exists, for this one, readonly is not set:

readonly is not set

Update 3

I'm pretty sure the problem is the ZoomWin plugin. I had switched it up to a newer version, and it simply didn't work right. So I stopped using it for a bit, and didn't have this issue. Then switched it back, b/c I miss its functionality (it's my favourite vim plugin), and the problems started again. Possibly it's ZoomWin in conjunction with NerdTree window. Probably not the lib authors' faults, vim in general seems fragile and buggy. Maybe I'll try NeoVim, see if they've done a better job. Maybe it's time to try Atom or Emacs again.

like image 870
Joshua Cheek Avatar asked Sep 27 '14 00:09

Joshua Cheek


People also ask

How do I override a readonly in Vim?

You can press Esc , and then U , and then type :q . First come out of the vim editor using: :qa!

How do I save overwrite in Vim?

To save the file and exit the editor simultaneously, press Esc to switch to normal mode, type :wq and hit Enter . Another command to save a file and quit Vim is :x .

How do I open Vim in write mode?

Press Esc to enter Command mode, and then type :wq to write and quit the file. The other, quicker option is to use the keyboard shortcut ZZ to write and quit. To the non-vi initiated, write means save, and quit means exit vi.

Does Vim load entire file into memory?

Yes, Vim loads the whole file into memory.


1 Answers

It seems that if there were read errors opening the file, Vim will print an error on :w. This can be seen by running :f:

"MANIFEST.in" [Read errors] 1 line --100%--

The errors aren't necessarily errors in reading the contents of file; they can be caused by a plugin.

like image 143
ash Avatar answered Sep 23 '22 00:09

ash