Loading ...
Sorry, an error occurred while loading the content.

Re: case insensitive glob

Expand Messages
  • Eddy Zhao
    Sorry, forget to mention, I m using vim on linux.
    Message 1 of 4 , Sep 1, 2006
    • 0 Attachment
      Sorry, forget to mention, I'm using vim on linux.

      2006/9/1, Eddy Zhao <eddy.y.zhao@...>:
      > Hi,
      >
      > I'm using vim 7.0, and find glob is case-sensitive. Is there way
      > to make glob case-insensitive ? I'm asking this because some plugin
      > (like lookupfile) rely on glob, and case-sensitive globbing is very
      > inconvenient. (BTW, I'm finding on windows glob is case-insensitive)
      >
      > Thanks
      > Eddy
      >
    • A.J.Mechelynck
      ... glob() reflects the behaviour of the underlying filesystem. In Windows, dir FoO*.* will list both FOOBAR.TXT and foobar.htm if present. In Linux, ls -l
      Message 2 of 4 , Sep 1, 2006
      • 0 Attachment
        Eddy Zhao wrote:
        > Sorry, forget to mention, I'm using vim on linux.
        >
        > 2006/9/1, Eddy Zhao <eddy.y.zhao@...>:
        >> Hi,
        >>
        >> I'm using vim 7.0, and find glob is case-sensitive. Is there way
        >> to make glob case-insensitive ? I'm asking this because some plugin
        >> (like lookupfile) rely on glob, and case-sensitive globbing is very
        >> inconvenient. (BTW, I'm finding on windows glob is case-insensitive)
        >>
        >> Thanks
        >> Eddy
        >>
        >

        glob() reflects the behaviour of the underlying filesystem. In Windows,
        "dir FoO*.*" will list both FOOBAR.TXT and foobar.htm if present. In
        Linux, "ls -l FoO*" will list neither, even if present. That's why
        glob() is case-insensitive in Windows and case-sensitive in Linux.


        Best regards,
        Tony.
      • Tim Chase
        ... I suppose one could create a custom GlobIC() function that would call vanilla glob() on Dos/Win32 platforms, and massage the search string on
        Message 3 of 4 , Sep 1, 2006
        • 0 Attachment
          > glob() reflects the behaviour of the underlying filesystem. In Windows,
          > "dir FoO*.*" will list both FOOBAR.TXT and foobar.htm if present. In
          > Linux, "ls -l FoO*" will list neither, even if present. That's why
          > glob() is case-insensitive in Windows and case-sensitive in Linux.

          I suppose one could create a custom GlobIC() function that would
          call vanilla glob() on Dos/Win32 platforms, and massage the
          search string on *nix...something like this 100% untested

          function! GlobIC(searchstring)
          if has('unix')
          let l:s = substitute(a:searchstring, '\a', '[\l\1\u\1]', 'g')
          else
          let l:s = a:searchstring
          endif
          return glob(l:s)
          endfunc


          (that replacement is "backslash ell, backslash one, backslash
          ewe, backslash one")


          It would only allow through the "*" and "?" metachars (which both
          platforms support), as it would likely hose any character-classes
          on the *nix side of things (e.g. "file_[a-z]*.txt" would get
          mistakenly translated to "file_[[aA]-[zZ]]*.txt")

          However, it might be a step towards a solution for you.

          -tim
        Your message has been successfully submitted and would be delivered to recipients shortly.