This works great!

Thanks
Eddy

2006/5/1, Yakov Lerner <[EMAIL PROTECTED]>:
On 4/30/06, Eddy Zhao <[EMAIL PROTECTED]> wrote:
> Very often,  when I
>  - snip some notes from web
>  - paste them into an empty buffer
>  - yank the key sentence as filename
>  - then try to :write
>
> Vim report "E77: Too many file names".  How can the spaces
> in filename be automatically escaped when I save the file?

Use the :W instead of :w, and :W! instead of :w!. See below.
It automatically escapes spaces for you.

command! -bang -nargs=* W :call W(<q-bang>, <q-args>)

function! W(bang, filename)
    :exe "w".a:bang." ". substitute(a:filename, ' ', '\\ ', 'g')
endfu

Yakov

Reply via email to