On Sun, 30 Apr 2006, Yakov Lerner wrote:

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

In addition to Yakov's suggestion, you can perform

  :let @@=escape(@@,' ')

after you yank the key sentence as the filename. It should escape spaces
once you paste for :write.

HTH.
--
Gerald

Reply via email to