Hi,

I just wrote a simple function in vim script and needed 12 backslashes
to escape a space!  I haven't sat down and tried to figure out exactly
why it needs that many, but it won't work with less.

It's a useful function too, so here it is:

""""""""""""""""""""""""
func! AddDir(setting, path)
    if isdirectory(a:path)
        exec "set " . a:setting "+=" . substitute(a:path, " ", "\\\\\\\\\\\\ ",
"g")
    endif
endfunc
""""""""""""""""""""""""

Then in your .vimrc/_vimrc file you can use it like this:

""""""""""""""""""""""""
call AddDir("path", "F:/Program Files/Microsoft Platform SDK/VC/include")
""""""""""""""""""""""""

The directory path will be added to the given setting if and only if
it exists, and the path may be provided without having to escape
spaces.  For me this is handy as it allows me to use the same .vimrc
on different machines with different paths, without the 'path' setting
getting out of hand.

I also have a similar function called AddFile, where isdirectory is
replaced with filereadable.  Useful for the 'dict' setting.

12 backslashes does seem a bit excessive though :-)
Rob.

--

Robert Webb,
MineSweeper3D - Take Minesweeper to a whole new dimension!
http://www.software3d.com/Mines3D


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui