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

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

Expand Messages
  • Jürgen Krämer
    Feb 21, 2013
    • 0 Attachment

      Paul 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).

      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 $HOME").

      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.

      Hope this helps.


      Sometimes I think the surest sign that intelligent life exists elsewhere
      in the universe is that none of it has tried to contact us. (Calvin)

      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.
    • Show all 7 messages in this topic