VIM on Windows Work Laptop

189 views
Skip to first unread message

Jack corley

unread,
Mar 7, 2020, 4:35:00 PM3/7/20
to vim_use
Hey, guys I recently started a position that requires me to use a windows workstation but I would like to have access to vim and the plugins I normally would use.  I feel infinitely slower doing basic tasks without it. I managed to install the windows version but I am not fully understanding where the vimrc file belongs and how to get plug up and running with it so I can configure things and utilize plugins. Any tips or suggestions are appreciated. So far I have tried modifying the _vimrc in my x86 programs file and added the autoload directory like the Plug installation requires. But when I launch vim it doesn't seem to be recognizing my _vimrc changes or location maybe. 

BPJ

unread,
Mar 7, 2020, 5:17:23 PM3/7/20
to vim_use
For starters it is called _vimrc on windows, and according to :h _vimrc it lives in $HOME/vimfiles/, which is what ~/.vim is called on Windows.


Den lör 7 mars 2020 22:35Jack corley <jdco...@gmail.com> skrev:
Hey, guys I recently started a position that requires me to use a windows workstation but I would like to have access to vim and the plugins I normally would use.  I feel infinitely slower doing basic tasks without it. I managed to install the windows version but I am not fully understanding where the vimrc file belongs and how to get plug up and running with it so I can configure things and utilize plugins. Any tips or suggestions are appreciated. So far I have tried modifying the _vimrc in my x86 programs file and added the autoload directory like the Plug installation requires. But when I launch vim it doesn't seem to be recognizing my _vimrc changes or location maybe. 

--
--
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+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/8850952a-055a-479d-9692-ddcb50cc09de%40googlegroups.com.

Enno

unread,
Mar 8, 2020, 12:35:06 AM3/8/20
to vim_use
See :help vimfiles for the location of the configuration files on each operating system.
This Vimscript code set the global variable g:vimfiles_dir to their path:

  let s: vimfiles_dir = split(&runtimepath, ',')[0]
  if isdirectory(s:vimfiles_dir)
    let g:vimfiles_dir = s:vimfiles_dir
  elseif if has('unix')
    let g:vimfiles_dir = expand('$HOME') . '/.vim'
  else " if has('win32')
    " see :help vimfiles
    let g:vimfiles_dir = expand('$HOME') . '/vimfiles'
  endif
  unlet s:vimfiles_dir

This code then sources Plug independent of the operating system:

  if filereadable(expand(g:vimfiles_dir . '/plugs.vim'))
    exe 'source ' g:vimfiles_dir . '/plugs.vim'
  endif

To use '.vim' instead of 'vimfiles' on Windows, too, add this Vimscript code to _vimrc :

  if has('win32')
    set runtimepath=$HOME/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/.vim/after
  endif

Tony Mechelynck

unread,
Mar 8, 2020, 3:25:31 AM3/8/20
to Jack corley, vim_use
On Sat, Mar 7, 2020 at 10:34 PM Jack corley <jdco...@gmail.com> wrote:
>
> Hey, guys I recently started a position that requires me to use a windows workstation but I would like to have access to vim and the plugins I normally would use. I feel infinitely slower doing basic tasks without it. I managed to install the windows version but I am not fully understanding where the vimrc file belongs and how to get plug up and running with it so I can configure things and utilize plugins. Any tips or suggestions are appreciated. So far I have tried modifying the _vimrc in my x86 programs file and added the autoload directory like the Plug installation requires. But when I launch vim it doesn't seem to be recognizing my _vimrc changes or location maybe.

On Unix Vim looks for a startup file named .vimrc, on Windows for one
named _vimrc. In both cases it looks for it in your home directory —
and if $HOME (or, in Windows parlance, %HOME%) is not defined on
Windows, $HOMEDRIVE$HOMEPATH (i.e. %HOMEDRIVE%%HOMEPATH%) is a
fallback location. If the vimrc is not found there, Vim looks for it
on Unix as ~/.vim/vimrc or on Windows as ~/vimfiles/vimrc (i.e., in
the latter case, %HOME%\vimfiles\vimrc or
%HOMEDRIVE%%HOMEPATH%\vimfiles\vimrc). Note that a vimrc in .vim (for
Unix) or in vimfiles (for Windows) must NOT have a . or _ at the start
of its filename.

All this, and more (e.g. how to invoke Vim so as to disregard an
existing vimrc) is explained under ":help vimrc".

For the plugins, they are in the plugin/ subdirectory (for global
plugins) of one of the directories mentioned in the 'runtimepath'
option. These are normally the following:
$HOME/.vim/ (Unix) or $HOME/vimfiles/ (Windows) for user-specific full scripts
$VIM/vimfiles/ for system-wide scripts, usually put there by a system
administrator
$VIMRUNTIME/ _only_ for scripts distributed together with Vim. Any Vim
update may silently modify them.
$VIM/vimfiles/after/ for system-wide snippets overriding any of the above
$HOME/.vim/after/ (Unix) or $HOME/vimfiles/after/ (Windows) for
user-specific snippets overriding any of the above.

All these five directory trees have the same layout, and if a script
looked-for in one of them is absent, it is no error: the result is the
same as if the script had been present but empty. In the case of
global plugins, however, all of them are sourced in the order they are
found, unless you disable them all by means of a command-line switch
which can take several forms, see ":help --noplugin".

In addition, you may have "packages" which add additional directories
to the above five.
See
:help 'runtimepath'
:help packages
:help plugin (which is a whole chapter about the various kinds
of plugins)

HTH,
Tony.

Tekki

unread,
Mar 9, 2020, 3:10:20 AM3/9/20
to vim_use
Did you consider to use WSL2 and the new Windows terminal? That's how I work with Vim most of the time, even if I edit Windows files.

joh...@nacs.net

unread,
Mar 10, 2020, 9:07:23 AM3/10/20
to vim...@googlegroups.com
There have already been many good answers, though there
are a few points I can add.

If Vim configurtion or script files will be migrated back
and forth between Windows and Unix, keeping them in
fileformat=Unix with simple NL line breaks will make this
easier. Option 'fileformat' aka 'ff' can be toggled to
change files at will between "unix" and "dos" (or "mac")
format.

The vimfiles directory can be placed as a subdirectory
under the main Vim installation container directory,
although if this happens to be under $ProgramFiles or
$ProgramFiles(x86) the files there will be protected by
Windows; Administrative privileges for a Vim instance will
be needed to change them.

Hmm, actually $ProgramFiles(x86) behaves a little strange
when checked with the :echo command; it echos the correct
value but also gives:
E121: Undefined variable: x86
Then again what could go wrong with including parentheses
in an identifier name? Thanks, Microsoft, spaces weren't
bad enough.
Reply all
Reply to author
Forward
0 new messages