Yakov Lerner wrote:
I want to make saving of unnamed buffers possible as follows:
When I do :w on a unnamed buffer, I want it to save to the
file /tmp/N where N is number.
I tried the simple code below, but it does not work. I am getting
'E32: No file name', same error as without this code.
How do I fix it ?
Thanks
Yakov
" ------------ attempt to save unnamed buffer to file /tmp/N -----
au BufWritePre if(expand('%') == '') | exe "filename ".TempName() | endif
function! TempName()
let x=1
while filereadable("/tmp/".x)
let x = x + 1
endwhile
return "/tmp/".x
endfun
Instead of ":filename" which AFAIK is not a Vim command, try using
":file" or ":saveas" instead.
Best regards,
Tony.