On 7/31/06, Bob Hiestand <[EMAIL PROTECTED]> wrote:
Question two:

Is there a way to set the buffer name without the name being subject
to shell metacharacter expansion?

Easy. Here's the function that sets buffername without escaping.

function! LiteralSetBufferName(name)
   " we need to escape following chars: $ ` ~ \ % # * ?
   let escaped = substitute(a:name, '[$`~%#*?\\]', '\\&', 'g')
   exe "file ".escaped
endfun
:command! -nargs=1 FILE :call LiteralSetBufferName(<q-args>)

And here's remapping of :file command to this function/command:

cabbrev f <c-R>=(getcmdtype()==':' && getcmdpos()==1 ? 'F' : 'f')<cr>
cabbrev fi <c-R>=(getcmdtype()==':' && getcmdpos()==1 ? 'FI' : 'fi')<cr>
cabbrev fil <c-R>=(getcmdtype()==':' && getcmdpos()==1 ? 'FIL' : 'fil')<cr>
cabbrev file <c-R>=(getcmdtype()==':' && getcmdpos()==1 ? 'FILE' : 'file')<cr>

Yakov

Reply via email to