On Apr 19, 6:05 pm, Stahlman Family <[email protected]> wrote:
> AndyHancock wrote:
>> I've been kluging an old version of BufExplorer plugin to trim down
>> displayed paths when invoked by different gvim versions (Solaris,
>> Windows, and Cygwin).  Without such trimming, BufExplorer might
>> display:
>>
>>   5 %    Temp.txt c:\cygwin\home\Administrator\Temp
>>   1 #    diff.out c:\cygwin\home\Administrator\Temp
>>
>> I've managed to cobble the code so that in Solaris and Cygwin, it is
>> displayed as
>>
>>   5 %    Temp.txt ~\Temp
>>   1 #    diff.out ~\Temp
>>
>> However, I'm having some trouble making the code work with Windows vim
>> 7.2.  Currently, I am using the code:
>>
>>    let _cfile = _cfile." ".substitute(
>>       \ expand("#"._cnr.":p:h"),
>>       \ "[Cc]:\\cygwin\\home\\".$USERNAME, "~", "g" )
>>
>> Here, _cfile is the basename of the file path before the statement is
>> excuted.  This code doesn't do anything.  As a debugging test,
>> however, this "works":
>>
>>    let _cfile =
>>       \ _cfile." ".substitute( expand("#"._cnr.":p:h"),
>>       \ "c:\\", "~", "g" )
>>
>> It works in the sense that "c:\" in the file path is replaced by "~".
>> This test "works" too:
>>
>>    let _cfile =
>>       \ _cfile." ".substitute( expand("#"._cnr.":p:h"),
>>       \ "cygwin", "~", "g" )
>>
>> It works in the sense that "cygwin" is replaced by "~".
>>
>> Strangely enough, the combination of the above two tests does not
>> work:
>
> When you specify a pattern such as "c:\\", the 2 backslashes become 1
> prior to compilation of the regex. Thus, what the regex compiler sees is
>   'c:\'. Since nothing follows the backslash, it can't be an escape, so
> the regex engine matches it as a literal backslash character. Similarly,
> when you specify a pattern such as "c:\\cygwin", the 2 backslashes
> become 1 prior to compilation of the regex. Thus, what the regex
> compiler sees is 'c:\cygwin'. Note that something (the `c' in cygwin)
> now follows the backslash, so the regex engine interprets the backslash
> as an escape, and assumes you want to match `c:', followed by a literal
> `c' (indicated by `\c'), followed by `ygwin'. In other words, the regex
> engine is looking for...
> c:cygwin
> ...which is probably not what you want. To match what I think you want,
> you should use 'c:\\cygwin' instead of "c:\\cygwin". If you wanted to
> use double quotes, it would be "c:\\\\cygwin".

Brett, Thanks!  Single quotes work.

I tried to dig up info on how single and double quotes are
interpretted in vim script.  All I can find were quotations lauding
vim (much deserved!).  I even googled for

   vim single-quote double-quote

Finally, I assumed that vim script syntax had some inheritance from
ed.  This is just a speculative stab, since I have no idea aside from
the fact that vi commands looked like ed commands.  However, vim
script code uses versions of vi commands with a syntax that resemble
third generation languages more than cryptic ed commands.  Google hits
on ed commands didn't turn up anything relevant.

Is there documentation on the vim script commands that depart from the
vi command syntax (for commands started with colon ":")?
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to