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

Knowing the name vim was invoked under

Expand Messages
  • DervishD
    Hi all :) I would like to share the same .vimrc for vim and view , so I can use view as a pager without having to use -u in the command line. So far,
    Message 1 of 4 , Dec 1, 2006
    • 0 Attachment
      Hi all :)

      I would like to share the same .vimrc for "vim" and "view", so I can
      use "view" as a pager without having to use "-u" in the command line. So
      far, I've thought that the only way of knowing if I'm under "vim" or
      "view" mode is to check the value of "readonly". Not perfect, but it
      will do.

      The problem is that I would like to use vim with other
      "personalities" (different sets of options) depending on its invocation
      name. Can this be done? I haven't found in the documentation any
      function to retrieve the full command line, just the file argument list.

      Any suggestion about how to discriminate in the .vimrc file
      depending on the invocation name for vim?

      Thanks a lot in advance :)

      Raúl Núñez de Arenas Coronado

      --
      Linux Registered User 88736 | http://www.dervishd.net
      It's my PC and I'll cry if I want to... RAmen!
    • DervishD
      Hi Tony :) ... S*IT! I tried argc, argv, etc. but I didn t tried the simplest form: progname. Thanks a lot! ... I m going to use it just under my login, it
      Message 2 of 4 , Dec 3, 2006
      • 0 Attachment
        Hi Tony :)

        * A.J.Mechelynck <antoine.mechelynck@...> dixit:
        > DervishD wrote:

        > > The problem is that I would like to use vim with other
        > >"personalities" (different sets of options) depending on its
        > >invocation name. Can this be done? I haven't found in the
        > >documentation any function to retrieve the full command line, just
        > >the file argument list.
        > >
        > > Any suggestion about how to discriminate in the .vimrc file
        > >depending on the invocation name for vim?
        > >
        >
        > :help v:progname

        S*IT! I tried argc, argv, etc. but I didn't tried the simplest form:
        progname. Thanks a lot!

        > Note that sometimes Vim will get a progname with suffixes, e.g. gvimd
        > for a version of gvim compiled with debug information; or vim64.exe
        > for a Vim 6.4 kept for testing scripts. So in general I would
        > recommend testing using pattern-matching:

        I'm going to use it just under my login, it won't be installed as a
        system-wide mechanism, but I take this into acount if I ever install it
        as a global rc.

        > if v:progname =~? 'vim' " test for vim or gvim
        > if v:progname =~? '^r' " restricted mode

        > don't test for "if v:progname ~? 'view'", test for "if &readonly"

        That's how I do it right now, but I don't want to use the
        alternative configuration just because &readonly is set, I want to use
        based on the invocation name, at least for my system.

        Thanks a lot for your help :)))

        Raúl Núñez de Arenas Coronado

        --
        Linux Registered User 88736 | http://www.dervishd.net
        It's my PC and I'll cry if I want to... RAmen!
      • A.J.Mechelynck
        DervishD wrote: [...] ... Well, note then that vim -R is equivalent to view , gvim -d to gvimdiff etc. (see the list of names starting at :help ex ).
        Message 3 of 4 , Dec 3, 2006
        • 0 Attachment
          DervishD wrote:
          [...]
          > That's how I do it right now, but I don't want to use the
          > alternative configuration just because &readonly is set, I want to use
          > based on the invocation name, at least for my system.
          >
          > Thanks a lot for your help :)))
          >
          > Raúl Núñez de Arenas Coronado
          >

          Well, note then that "vim -R" is equivalent to "view", "gvim -d" to "gvimdiff"
          etc. (see the list of names starting at ":help ex"). As long as you keep this
          in mind, do as you like.

          AFAIK, there is no "easy" way to capture the command-line options from inside
          the vimrc.


          Best regards,
          Tony.
        • DervishD
          Hi Tony :) ... Yes, I ve took a look at the sources, just in case, but thanks for the information. The list of names and equivalences is vey useful, thanks :)
          Message 4 of 4 , Dec 6, 2006
          • 0 Attachment
            Hi Tony :)

            * A.J.Mechelynck <antoine.mechelynck@...> dixit:
            > DervishD wrote:
            > > That's how I do it right now, but I don't want to use the
            > >alternative configuration just because &readonly is set, I want to use
            > >based on the invocation name, at least for my system.
            > Well, note then that "vim -R" is equivalent to "view", "gvim -d" to
            > "gvimdiff" etc. (see the list of names starting at ":help ex"). As
            > long as you keep this in mind, do as you like.

            Yes, I've took a look at the sources, just in case, but thanks for
            the information. The list of names and equivalences is vey useful,
            thanks :)

            > AFAIK, there is no "easy" way to capture the command-line options from
            > inside the vimrc.

            By now, just knowing "v:progname" is enough for me. Maybe in the
            future I must change the way I discriminate, I don't know.

            Raúl Núñez de Arenas Coronado

            --
            Linux Registered User 88736 | http://www.dervishd.net
            It's my PC and I'll cry if I want to... RAmen!
          Your message has been successfully submitted and would be delivered to recipients shortly.