DervishD wrote:
    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


        :help v:progname

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:

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

etc. However, some "names of Vim" are equivalent with generic names plus command-line arguments: e.g. "gvim -R" is equivalent to "gview", "vim -Z" is equivalent to "rvim" etc. So other testing methods are maybe more reliable:

don't test for "if v:progname =~? '^g'", test for "if has('gui_running')
don't test for "if v:progname ~? 'view'", test for "if &readonly"

etc.


Best regards,
Tony.

Reply via email to