On 05/15/12 10:20, Ben Fritz wrote:
> On Tuesday, May 15, 2012 2:49:38 AM UTC-5, JohnBeckett wrote:
>> 1. Create file bad.tmp by executing the following line.
>> :call writefile(["Very important file \x8D"], 'bad.tmp')
>>
>> 2. Start Vim editing the file and enter commands, as below.
>> vim -N -u NONE bad.tmp
>> :set fenc=cp857
> 
> What if, right here, Vim were to check the buffer contents to see
> if all characters in the file can actually be converted to the
> new fenc setting, and issue a warning if not? It's not something
> Vim does currently...but I don't see why it couldn't. And I'd
> like to know if I do something stupid *when I do it*, not when I
> try to write the file and end up killing my file.

I like Ben's suggestion on this one.  Concerns that come to mind:

- warnings might interrupt scripts that run

- how it would interact with the "let &setting=" syntax

- would this just be a message (that gets ignored?) or a prompted
"do you want to undo this catastrophically dangerous action?"


>> 4. Panic and do what has always worked in the past:
>> :q!
>>
> 
> Right, to me, :q! means "oh crap I didn't mean to do that, GET ME OUT!"

The caveat here is that, if you have performed an action that might
have fouled up the file-on-disk, your only valid source might be
what is in Vim's buffer.  So if you get a warning, think hard before
attempting to quit.  E.g.

  :e important.txt
  :!rm %

get "E211: File "important.txt" no longer available" message.  Panic and

  :q!

Clearly, vim shouldn't try to override what you expressly did (I
wouldn't want Vim to re-save the file to the disk).  In this case,
even ":q" abandon the content without complaint.

-tim





-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to