简体   繁体   English

将 vimrc 转换为 Windows

[英]Translating a vimrc to Windows

I recently installed Vim for Windows, and I am trying to port my vimrc from Linux.我最近为 Windows 安装了 Vim,我正在尝试从 Linux 移植我的 vimrc。

The bash script in the vimrc I need to make work is as follows :我需要工作的 vimrc 中的 bash 脚本如下:

set nocompatible
source $VIM
behave mswin

let iCanHazVundle=1
let vundle_readme=expand('$VIM/bundle/vundle/README.md')
if !filereadable(vundle_readme)
    echo "Installing Vundle..."
    echo ""
    silent !mkdir $VIM/bundle
    silent !git clone https://github.com/gmarik/vundle $VIM/bundle/vundle
    let iCanHazVundle=0
endif

" required for vundle
filetype off

set rtp+=$VIM/bundle/vundle/
call vundle#rc()

" let Vundle manage Vundle
" required!
Bundle 'Rip-Rip/clang_complete

Notice that this basically just checks to see if my Vundle packages have been installed or not(based on the existence of a readme), and installs them if not.请注意,这基本上只是检查我的 Vundle 包是否已安装(基于自述文件的存在),如果没有安装它们。 I included the first Bundle call to give you an idea of how it executes.我包含了第一个Bundle调用,让您了解它是如何执行的。 The only difference in the code below and my original Linux Script is that I replaced all entries to the Linux file system: ~/.vim with $VIM .下面的代码和我原来的 Linux 脚本的唯一区别是我用$VIM替换了 Linux 文件系统的所有条目: ~/.vim When I run :echo $VIM in the Windows Vim terminal it gives me the proper path.当我在 Windows Vim 终端中运行 :echo $VIM 时,它给了我正确的路径。 The script runs, however it always fails to call vundle#rc() and subsequently fails outright for all the Bundle calls.脚本运行,但是它总是无法调用 vundle#rc() 并且随后对所有Bundle调用完全失败。 Note that I do have the msysGit installed.请注意,我确实安装了 msysGit。

EDIT The mkdir function was actually working and my environment variable was typed wrong into the console.编辑mkdir 函数实际上正在工作,我的环境变量在控制台中输入错误。 Also, msysGit needed to be upgraded (failing for unknown reasons. Now I am faced with the problem :另外,msysGit 需要升级(由于未知原因失败。现在我面临的问题是:

Error detected while processing C:\Program Files (x86)\Vim\_vimrc:
line   58:
E117: Unknown function: vundle#rc
line   62:
E492: Not an editor command: Bundle 'Rip-Rip/clang_complete'

Any suggestions are greatly appreciated!任何建议都非常感谢!

It seems that the main problem you have is with the line,看来你的主要问题是线路,

silent !mkdir $VIM/bundle

Using the !使用! shell escape, this tires to call the external command mkdir . shell 逃逸,这厌倦了调用外部命令mkdir However, this command doesn't exist on Windows (unless you've installed Cygwin or similar and the GNU tools are in your path) and the use of silent means the error message is not printed so screen.但是,此命令在 Windows 上不存在(除非您已经安装了 Cygwin 或类似工具并且 GNU 工具在您的路径中)并且使用silent意味着不会在屏幕上打印错误消息。

To create the directory in any operating system, you can use Vim's own built-in mkdir() function.要在任何操作系统中创建目录,您可以使用 Vim 自己的内置mkdir()函数。 The following command using string concatenation (using the . operator) to build the directory path should work:以下使用字符串连接(使用.运算符)来构建目录路径的命令应该可以工作:

call mkdir($VIM . "/bundle")

If the directory is created correctly, the following external git command should work as long as you have git installed and available in your Windows PATH .如果目录创建正确,那么只要您安装了git并且在 Windows PATH可用,以下外部git命令就应该可以工作。

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

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