为当前shell配置vim

The*_*ant 1 vim bash

我无法更改我的.vimrc,因为我使用的是多人使用的登录信息.我希望能够在不更改vimrc的情况下为我当前的shell设置vim选项.要么在调用时将参数传递给vim,要么将其传递给vim.我希望能够设置以下内容:

    :set nu
    :set shiftwidth=4
    :set tabstop=4
    :set ai
    :set expandtab
Run Code Online (Sandbox Code Playgroud)

这是一个很长的镜头,但任何想法将不胜感激

Jon*_*ler 6

:help EXINIT进来vim揭示:

      *VIMINIT* *.vimrc* *_vimrc* *EXINIT* *.exrc* *_exrc* *$MYVIMRC*
 c. Four places are searched for initializations.  The first that exists
    is used, the others are ignored.  The $MYVIMRC environment variable is
    set to the file that was first found, unless $MYVIMRC was already set
    and when using VIMINIT.
    -  The environment variable VIMINIT (see also |compatible-default|) (*)
       The value of $VIMINIT is used as an Ex command line.
    -  The user vimrc file(s):
                "$HOME/.vimrc"      (for Unix and OS/2) (*)
                "s:.vimrc"          (for Amiga) (*)
                "home:.vimrc"       (for Amiga) (*)
                "$VIM/.vimrc"       (for OS/2 and Amiga) (*)
                "$HOME/_vimrc"      (for MS-DOS and Win32) (*)
                "$VIM/_vimrc"       (for MS-DOS and Win32) (*)
            Note: For Unix, OS/2 and Amiga, when ".vimrc" does not exist,
            "_vimrc" is also tried, in case an MS-DOS compatible file
            system is used.  For MS-DOS and Win32 ".vimrc" is checked
            after "_vimrc", in case long file names are used.
            Note: For MS-DOS and Win32, "$HOME" is checked first.  If no
            "_vimrc" or ".vimrc" is found there, "$VIM" is tried.
            See |$VIM| for when $VIM is not set.
    -  The environment variable EXINIT.
       The value of $EXINIT is used as an Ex command line.
    -  The user exrc file(s).  Same as for the user vimrc file, but with
       "vimrc" replaced by "exrc".  But only one of ".exrc" and "_exrc" is
       used, depending on the system.  And without the (*)!
Run Code Online (Sandbox Code Playgroud)

这表示设置环境变量$VIMINIT优先,然后是.vimrc文件,然后是设置$EXINIT,然后是.exrc文件.这与我发现的一致 - 不是很令人惊讶.我有一个.vimrc文件; 它优先于$EXINIT我设置的变量,但设置$VIMINIT工作,覆盖.vimrc文件.