136345Re: _vimrc not run when invoking gvim on text file from context menu
- Feb 22, 2013On Feb 22, 2:52 am, Jürgen Krämer <jottka...@...> wrote:
>Paul wrote:Thanks for that, Jurgen.
>> 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).
> the $HOME variable is the culprit. If you don't give the -u
> parameter on the command line Vim looks for its _vimrc in the
> directory defined by $HOME. On Windows, if $HOME does not exist it
> is constructed internally from $HOMEDRIVE$HOMEPATH (see ":help
> So either you have to put your _vimrc on the network drive given by
> $HOME, or you have to modify the command that is executed when you
> click on "Edit with vim".
> I have never used this context menu entry much and for the only
> computer that has it I'm not so sure if I haven't tinkered around
> with it, so the following might be of no help:
> - Open the registry editor by executing regedit.exe.
> - Search for the Text "Edit with Vim". If one of the letters in the
> context menu is underlined put an ampersand in front of it, e.g.
> I had to actually search for "Edit with &Vim".
> - You should find an entry with an sub-entry called "Command".
> This sub-entry should have a key called "(Standard)" or
> "(Default)" or something like this which holds the command to
> start Vim.
> - Modify it so that it includes "-u $USERPROFILE\.vimrc" after the
> program name, i.e. it should like
> <Path to Vim>\Vim.exe -u $USERPROFILE\.vimrc "%1"
> Instead of "%1" you can also write "%L" which might be better for
> long file names.
I don't have the ability to change the registry.
However, I found that setting the user-specific Windows environment
variable VIMINIT works. However, one has to be careful about the fact
that all subprocesses inherit this. For example, if you run cygwin's
bash shell, it will also inherit this. However, cygwin's bash uses
posix style paths, so if VIMINIT contains DOS style paths, it will
cause problems. As I said, my solution was to unset VIMINIT in my
bash startup file ".bashrc". It's messy, having to undo something in
one environment that was setup in another environment, but it's the
nature of using global variables.
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@....
For more options, visit https://groups.google.com/groups/opt_out.
- << Previous post in topic Next post in topic >>