我正在尝试在Windows 7计算机上使用gVim,并遇到以下问题:
每当我尝试更改_vimrc文件时,就会收到一条消息,指出我没有权限保存在此位置。 这是在我的家用电脑上。
我似乎无法更改编辑文件保存的目录。 它们都保存在我的桌面上。 我尝试了:set dir =路径,但没有成功。
我想运行vimtutor; 但是,每当我在cmd中输入vimtutor时,vim会闪现一秒钟然后关闭。
如何更改_vimrc文件以及如何设置编辑文件的目标?
我正在尝试在Windows 7计算机上使用gVim,并遇到以下问题:
每当我尝试更改_vimrc文件时,就会收到一条消息,指出我没有权限保存在此位置。 这是在我的家用电脑上。
我似乎无法更改编辑文件保存的目录。 它们都保存在我的桌面上。 我尝试了:set dir =路径,但没有成功。
我想运行vimtutor; 但是,每当我在cmd中输入vimtutor时,vim会闪现一秒钟然后关闭。
如何更改_vimrc文件以及如何设置编辑文件的目标?
我发现很多人对此有不同的做法。以下是我在Windows上组织配置的方法:
%PROGRAMFILES%
或%PROGRAMFILES(x86)%
中编写或修改文件。.vim
文件夹和一个.vimrc
文件中。.vim
文件夹和_vimrc
文件放在%USERPROFILE%
中;对于安装了cygwin的机器,我将.vim
文件夹和_vimrc
文件放在我的cygwin用户主目录下。%HOME%
在Windows OOTB(开箱即用)中未定义,因此我需要定义它。我发现使用setx.exe
很容易...
setx HOME %USERPROFILE%
或 setx HOME d:\cygwin\home\myname
.vim
文件夹和_vimrc
文件复制/存储在%HOME%
中。但我喜欢将它们保存在另一个git repo中并进行链接。在Windows上,我使用mlink /d %HOME%\.vim location_of_vim_folder
将.vim
文件夹链接起来。然后使用mlink /h %HOME%\_vimrc location_of_dot_vimrc_file
将.vimrc
文件链接到_vimrc
文件。%HOME%
文件夹的写入权限...这应该解决了您的权限问题。(您需要是管理员才能写入%PROGRAMFILES%
或%PROGRAMFILES(x86)%
)在我的vimrc
中,我有一些针对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 )
_vimrc
文件在哪个位置?它应该在你的用户目录中。 - romainl_vimrc
写在你的用户目录下。 - romainlC:\users\username\_vimrc
和c:\users\username\vimfiles\
文件夹。 - romainl