I am trying to get gVim working on a windows 7 machine and am having the following problems:
Whenever I try to change the _vimrc file, I get a message saying that I don't have permission to save in this location. This is on my home pc btw.
I can't seem to change the directory where the files I edit are being saved. They are all being saved to my desktop at the moment. I tried :set dir=path to where I want to save... with no success.
I wanted to run through vimtutor; however, whenever I type vimtutor into cmd, vim flashes open for a second then closes.
How do I alter the _vimrc file and how do I set the destination for edited files?
Vim is a powerful code editor. So powerful that both Linux and Mac have it installed by default. But if you are using Windows as your operating system, you will need to install Vim separately. Fortunately, Microsoft makes it very easy to install Vim and get it running on your PC.
Vim is a flexible, efficient, and open-source terminal-based text editor. Vim stands for “Vi Improved”, which means it's a revamped version of the Vi text editor. Vim is regarded as one of the best text editors for security professionals and Linux users.
Functionally there is no difference between VIM and GVIM. They both work the same and have same keyboard sequences. VIM does not need a Graphical User Interface (GUI) and uses terminal shell environment to provide text editing features.
I find many people do it differently. Here's how I organize my configurations on windows.
%PROGRAMFILES%
or %PROGRAMFILES(x86)%
. .vim
folder and a .vimrc
file..vim
folder and my _vimrc
file in %USERPROFILE%
. On the ones with cygwin, I put my .vim
folder and my _vimrc
file in my cygwin user's home directory. %HOME%
is not defined on windows OOTB, so I define it. I find setx.exe
is easy...
setx HOME %USERPROFILE%
or setx HOME d:\cygwin\home\myname
.vim
folder and _vimrc
file in %HOME%
. But I like to keep them in a git repo elsewhere on my machine and link to them. On windows, I use mlink /d %HOME%\.vim location_of_vim_folder
to link the .vim
folder. And mlink /h %HOME%\_vimrc location_of_dot_vimrc_file
to link the .vimrc
to _vimrc
file.%HOME%
folder defined above... so this should solve your problem with permissions. (You need to be an administrator to write to %PROGRAMFILES%
or %PROGRAMFILES(x86)%
In my vimrc
, I have a bit of boiler plate stuff for windows:
"g:my_vim_dir is used elsewhere in my vim configurations
let g:my_vim_dir=expand("$HOME/.vim")
"$HOME/.vim and $HOME/.vim/after are in the &rtp on unix
"But on windows, they need to be added.
if has("win16") || has("win32") || has("win64")
"add g:my_vim_dir to the front of the runtimepath
execute "set rtp^=".g:my_vim_dir
"add g:my_vim_dir\after to the end of the runtimepath
execute "set rtp+=".g:my_vim_dir."\\after"
"Note, pathogen#infect() looks for the 'bundle' folder in each path
"of the &rtp, where the last dir in the '&rtp path' is not 'after'. The
"<path>\bundle\*\after folders will be added if and only if
"the corresponding <path>\after folder is in the &rtp before
"pathogen#infect() is called. So it is very important to add the above
"'after' folder.
"(This applies to vim plugins such as snipmate, tabularize, etc.. that
" are loaded by pathogen (and perhaps vundle too.))
" Not necessary, but I like to cleanup &rtp to use \ instead of /
" when on windows machines
let &rtp=substitute(&rtp,"[/]","\\","g")
"On windows, if called from cygwin or msys, the shell needs to be changed
"to cmd.exe to work with certain plugins that expect cmd.exe on windows versions
"of vim.
if &shell=~#'bash$'
set shell=$COMSPEC " sets shell to correct path for cmd.exe
endif
endif
"Then I load pathogen... (Or if you prefer, you could load vundle bundles here if you wish )
I can't seem to change the directory where the files I edit are being saved. They are all being saved to my desktop at the moment. I tried :set dir=path to where I want to save... with no success.
dir
is the location for swap files, which are special backing files used by Vim at runtime.
What you want is cd
or lcd
which changes the current directory. Type :help cd
inside of Vim for more info.
How do I alter the _vimrc file and how do I set the destination for edited files?
I have _vimrc in my Vim folder ($VIM), so when I want to put Vim on a new Windows machine I just copy my entire folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With