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

OS-agnostic path separator

Expand Messages
  • Nicolas Aggelidis
    hi guys, in my vimrc i have lines that look like source $HOME/.vim/key_bindings.vim this works fine in unix, but fails in windows.... I know that i can change
    Message 1 of 7 , May 1, 2009
    • 0 Attachment
      hi guys, in my vimrc i have lines that look like

      source $HOME/.vim/key_bindings.vim

      this works fine in unix, but fails in windows....
      I know that i can change the direction of the slashes, but i want to
      maintain the same sources for both windows and linux...

      Is it possible to write

      source $HOME/.vim/key_bindings.vim

      so that it is valid both on windows and on linux?

      thanks in advance for your answers!

      -nicolas

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Matt Wozniski
      ... This should work perfectly fine, both / and are recognized as path separators on windows. ... Are you sure that the file exists? $HOME/.vim isn t
      Message 2 of 7 , May 1, 2009
      • 0 Attachment
        On Fri, May 1, 2009 at 2:27 PM, Nicolas Aggelidis wrote:
        >
        > hi guys, in my vimrc i have lines that look like
        >
        > source $HOME/.vim/key_bindings.vim

        This should work perfectly fine, both / and \ are recognized as path
        separators on windows.

        > this works fine in unix, but fails in windows....
        > I know that i can change the direction of the slashes, but i want to
        > maintain the same sources for both windows and linux...

        Are you sure that the file exists? $HOME/.vim isn't normally around
        in windows, the normal per-user vim settings directory is
        $HOME/vimfiles

        ~Matt

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Gary Johnson
        ... Your source $HOME/.vim/key_bindings.vim should work fine in Windows. Vim automatically converts forward slashes in path names to backslashes before
        Message 3 of 7 , May 1, 2009
        • 0 Attachment
          On 2009-05-01, Nicolas Aggelidis wrote:
          > hi guys, in my vimrc i have lines that look like
          >
          > source $HOME/.vim/key_bindings.vim
          >
          > this works fine in unix, but fails in windows....
          > I know that i can change the direction of the slashes, but i want to
          > maintain the same sources for both windows and linux...
          >
          > Is it possible to write
          >
          > source $HOME/.vim/key_bindings.vim
          >
          > so that it is valid both on windows and on linux?
          >
          > thanks in advance for your answers!

          Your

          source $HOME/.vim/key_bindings.vim

          should work fine in Windows. Vim automatically converts forward
          slashes in path names to backslashes before calling Windows APIs.
          Are you sure that $HOME exists in the environment your Windows
          vim/gvim sees?

          Another thing to check is whether your $HOME on Windows contains
          spaces. Spaces in $HOME _might_ require quoting the path name, but
          I'm not sure and don't have an easy way to check at the moment.

          Regards,
          Gary



          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Nicolas Aggelidis
          ... you were right! i had renamed .vim file to _vim so this was the problem... --~--~---------~--~----~------------~-------~--~----~ You received this message
          Message 4 of 7 , May 1, 2009
          • 0 Attachment
            On Fri, May 1, 2009 at 9:39 PM, Matt Wozniski <mjw@...> wrote:
            > This should work perfectly fine, both / and \ are recognized as path
            > separators on windows.

            you were right! i had renamed .vim file to _vim so this was the problem...

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Nicolas Aggelidis
            Now i have the following code on my vimrc for windows if has( win16 ) || has( win32 ) || has( win64 ) source $HOME/vimfiles/key_bindings.vim source
            Message 5 of 7 , May 2, 2009
            • 0 Attachment
              Now i have the following code on my vimrc

              "for windows
              if has("win16") || has("win32") || has("win64")
              source $HOME/vimfiles/key_bindings.vim
              source $HOME/vimfiles/matchings.vim
              "for unix
              else
              source $HOME/.vim/key_bindings.vim
              source $HOME/.vim/matchings.vim

              endif


              i tried using a .vim folder in windows, but i noticed that in this
              case colorschemes(colors folder, located in .vim/colors) weren't
              loaded....


              -nicolas

              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_use" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • Gary Johnson
              ... That s because color schemes and other plugin files are loaded from directories rooted in the directories of your runtimepath . For Unix, the
              Message 6 of 7 , May 2, 2009
              • 0 Attachment
                On 2009-05-02, Nicolas Aggelidis wrote:
                > Now i have the following code on my vimrc
                >
                > "for windows
                > if has("win16") || has("win32") || has("win64")
                > source $HOME/vimfiles/key_bindings.vim
                > source $HOME/vimfiles/matchings.vim
                > "for unix
                > else
                > source $HOME/.vim/key_bindings.vim
                > source $HOME/.vim/matchings.vim
                >
                > endif
                >
                >
                > i tried using a .vim folder in windows, but i noticed that in this
                > case colorschemes(colors folder, located in .vim/colors) weren't
                > loaded....

                That's because color schemes and other plugin files are loaded from
                directories rooted in the directories of your 'runtimepath'. For
                Unix, the 'runtimepath' includes $HOME/.vim whereas for Windows, it
                includes instead $HOME/vimfiles. See

                :help runtimepath

                Is there any reason you need to source those files in your vimrc
                rather than putting them in your $HOME/.vim/plugin or
                $HOME/vimfiles/plugin directory and having vim source them
                automatically? If you could do that, you wouldn't need any source
                commands at all in your vimrc. See

                :help 05.4

                Regards,
                Gary



                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_use" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              • Matt Wozniski
                ... Even if you can t make them plugins, you can rely on the fact that they re in a directory that s in runtimepath on both OSes to remove the need for
                Message 7 of 7 , May 2, 2009
                • 0 Attachment
                  On Sat, May 2, 2009 at 4:41 AM, Gary Johnson wrote:
                  >
                  > On 2009-05-02, Nicolas Aggelidis wrote:
                  >> Now i have the following code on my vimrc
                  >>
                  >> "for windows
                  >> if has("win16") || has("win32") || has("win64")
                  >>       source  $HOME/vimfiles/key_bindings.vim
                  >>       source  $HOME/vimfiles/matchings.vim
                  >> "for unix
                  >> else
                  >>       source  $HOME/.vim/key_bindings.vim
                  >>       source  $HOME/.vim/matchings.vim
                  >>
                  >> endif
                  >>
                  >>
                  >> i tried using a .vim folder in windows, but i noticed that in this
                  >> case colorschemes(colors folder, located in .vim/colors) weren't
                  >> loaded....
                  >
                  > That's because color schemes and other plugin files are loaded from
                  > directories rooted in the directories of your 'runtimepath'.  For
                  > Unix, the 'runtimepath' includes $HOME/.vim whereas for Windows, it
                  > includes instead $HOME/vimfiles.  See
                  >
                  >    :help runtimepath
                  >
                  > Is there any reason you need to source those files in your vimrc
                  > rather than putting them in your $HOME/.vim/plugin or
                  > $HOME/vimfiles/plugin directory and having vim source them
                  > automatically?  If you could do that, you wouldn't need any source
                  > commands at all in your vimrc.  See
                  >
                  >    :help 05.4

                  Even if you can't make them plugins, you can rely on the fact that
                  they're in a directory that's in 'runtimepath' on both OSes to remove
                  the need for :source:

                  runtime key_bindings.vim
                  runtime matchings.vim

                  This should be pretty safe, since a) you're using the non ! form of
                  runtime, meaning only the first file in the runtimepath with each name
                  will be sourced, b) no default files with either of those names exist,
                  and c) you're placing them in the first directory of runtimepath in
                  both OSes

                  ~Matt

                  --~--~---------~--~----~------------~-------~--~----~
                  You received this message from the "vim_use" maillist.
                  For more information, visit http://www.vim.org/maillist.php
                  -~----------~----~----~----~------~----~------~--~---
                Your message has been successfully submitted and would be delivered to recipients shortly.