On Mon, Jul 13, 2009 at 9:45 PM, Tony Mechelynck wrote:
>
> [moving from vim_dev to vim_use]
> On 14/07/09 02:06, Toni Ruottu wrote:
>>
>> I'd be perfectly happy in doing :w! and getting the file saved under a
>> random named (like the ones you proposed) under ~/.vim/rubbish/. If
>> someone then wants to make more advanced user interfaces for exploring
>> the rubbish folder, that is fine with me too, but I'd do fine without
>> one. I don't mind tidying the files in that folder up every once in a
>> while, as long as my work is not interrupted with irritating problems,
>> like thinking of file names.
>
> Hm, after studying some parts of the help, I think it would be harder to
> implement than I thought, but I still think it could be done in
> vimscript. The question, however, is: is the game worth the candle?
>
> If you believe that thinking of a name when saving an unnamed buffer is
> too "irritating" for you to "think" of, well...
>
> Hm, here's an idea. Put this in your vimrc (untested, and, lurkers: this
> is for Unix/Linux, not Windows):
Unless I miss something, the only part of this that is really
Unix-specific is the :!mkdir - so, why not use :call mkdir(s:savedir,
'p') instead?
> let s:savedir = '~/.vim/rubbish'
> while !isdirectory(s:savedir)
> exe '!mkdir -p' s:savedir
> if v:shell_error
> echomsg 'Cannot create' s:savedir
> s:savedir = input('Type another path to use: ', '', 'dir')
> endif
> endwhile
> command -nargs=0 -bar -bang -complete=file -range=% W
> \ <line1>,<line2>call s:Write(<q-bang>)
> function s:Write(bang) range
> try
> exe a:firstline ',' a:lastline 'w' a:bang
> catch
> exe 'w' savedir . '/' . localtime() . '.txt'
> endtry
> endfunction
~Matt
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---