繁体   English   中英

在Windows上设置gVim

[英]Setting up gVim on windows

我试图让gVim在Windows 7机器上工作,并且遇到以下问题:

  • 每当我尝试更改_vimrc文件时,我都会收到一条消息,说我无权保存在此位置。 这是我的家用电脑顺便说一句。

  • 我似乎无法更改保存我编辑的文件的目录。 目前他们都被保存到我的桌面。 我尝试过:将dir = path设置为我要保存的位置......但没有成功。

我想通过vimtutor; 但是,每当我将vimtutor键入cmd时,vim会打开一秒钟然后关闭。

如何更改_vimrc文件以及如何为编辑的文件设置目标?

我发现许多人以不同的方式做到了。 这是我在Windows上组织配置的方式。

  • 首先请注意,我不相信我的vim配置与stock vim安装混合。 因此,我不会在%PROGRAMFILES%%PROGRAMFILES(x86)%编写或修改文件。
  • 我的vim配置适用于不同的平台(OS X,linux,windows)。 我将它们组织在.vim文件夹和.vimrc文件中。
  • 我的一些Windows机器有cygwin而其他机器没有。 在没有cygwin的那些,我把我的.vim文件夹和我的_vimrc文件放在%USERPROFILE% 在cygwin上,我把我的.vim文件夹和我的_vimrc文件放在我的cygwin用户的主目录中。
  • %HOME%未在Windows OOTB上定义,因此我定义它。 我发现setx.exe很容易......
    • 示例: setx HOME %USERPROFILE%setx HOME d:\\cygwin\\home\\myname
    • 或者,您可以通过控制面板添加环境变量。
  • 注意,您可以在%HOME%复制/存储.vim文件夹和_vimrc文件。 但是我喜欢把它们放在我机器上其他地方的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 ) 

我似乎无法更改保存我编辑的文件的目录。 目前他们都被保存到我的桌面。 我尝试过:将dir = path设置为我要保存的位置......但没有成功。

dir交换文件的位置, 交换文件是Vim在运行时使用的特殊后备文件。

你想要的是改变当前目录的cdlcd 键入:help cd内部的Vim获取更多信息。

如何更改_vimrc文件以及如何为编辑的文件设置目标?

我的Vim文件夹($ VIM)中有_vimrc,所以当我想将Vim放在新的Windows机器上时,我只需要复制整个文件夹。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM