On 12/19/12 08:44, Cesar Romani wrote:
> On 18/12/2012 10:58 p.m., Tim Chase wrote:
>> function! WriteShortcut(whole, name, url)
>>    call writefile(['[InternetShortcut]', 'URL='.(a:url), ''],
>> (a:name).'.txt')
>>    return a:whole
>> endfunction
> 
> Thanks, it works fine. If the name contained in the <a>...</a> contains
> illegal characters, such as : * ? / | how can I convert them to - or
> remove them?

Just modify where the file is named in the writefile() function.  I
suspect you want something like

  call writefile([...], substitute(a:name, '[:*?/|]', '_', 'g') .
'.txt')

to change the characters to a "_" (or you can just make it an empty
string to nuke them instead of translate them).  This is also where
I'd tweak to strip off whitespace from either side of the filename,
or other such cleanup.

-tim





-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to