Thursday, February 21, 2013

Re: _vimrc not run when invoking gvim on text file from context menu

>On Feb 21, 12:54 pm, Paul <paul.domas...@gmail.com> wrote:
> In Windows 7, I got a program "pinned" to the taskbar. It is
> basically a shortcut with the "Target" field set to:
>
> "C:\Program Files (x86)\Vim\vim73\gvim.exe" -u _vimrc
>
> and the "Start in" field set to $USERPROFILE. The _vimrc is also in
> $USERPROFILE, so it runs when gvim is started.
>
> However, when I right click on a text file in Windows Explorer and
> choose "Edit with vim", _vimrc is not run. Is something I can do to
> have it run?
>
> There are restrictions that a solution would have to observe. First
> is that I don't have admin privileges, so I can only stick _vimrc in
> places where $USERNAME can write. Also, $HOME is not a good place
> for it because it is set to a network drive. Finally, since I'm
> invoking gvim from the context menu, I'm not aware of a way to set
> environment variables for such an invocation of vim (unlike the case
> invoking vim from a script or command line).


On Feb 21, 1:05 pm, Paul <paul.domas...@gmail.com> wrote:
> I found the solution after a simple read of ":help vimrc". Set the
> environment variable VIMINIT to
>
> source $USERPROFILE\_vimrc
>
> For any other system or computing environment, I strongly suspect
> that one can use whatever path is to your _vimrc if it isn't
> $USERPROFILE \_vimrc.

I should clarify that it is the user-specific environment variable
VIMINIT in Windows that I set above.

However, it isn't the greatest solution. This environment variable
propagates where one does not expect. For example, it propagates to
cygwin's bash, which causes problems when one invokes gvim from the
bash command line. The installation of gvim being invoked from bash
is different from the Windows installation of gvim, and the path
$USERPROFILE/_vimrc doesn't work because $USERPROFILE uses Windows
path notation. The solution (being validated) is to set VIMINIT
explicitly in the bashrc file.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment