Win7下安裝配置gVim


本文根據vim官網的《Simple Steps to Help You Install gVim on Windows 7》【1】一文整理而成。

1. 下載gVim

在http://www.vim.org/download.php/pc 下找到“PC: MS-DOS and MS-Windows”,下載“gvim74.exe”【2】。

 

2. 安裝gVim

1. 安裝時可以選擇更改目錄(文中在 Users/用戶名 下面新建了一個目錄Vim,將gVim安裝在了該目錄下)。

2. 安裝時注意選擇‘Full’ option。

3. 在vimfiles 文件夾下,會有許多空文件夾。將它們全刪掉。

4. 將vim74文件夾下的“autoload”文件夾 剪切 到 vimfiles 文件夾下。

5. 在vimfiles 文件夾下新建文件夾 bundle。

 

3. 安裝msysGit

1. Win7下Git的安裝步驟請參考【3】。

2. 按照【3】的步驟安裝Git,發現在Win7 cmd下,不認 git 和curl 命令。這是由於在詢問是否修改環境變量時,選擇了“Use Git Bash Only”. 即只在msysGit提供的Shell。所以在Win7的 cmd下無法使用git命令。

需要重新安裝覆蓋一遍。不要卸載Git,重新運行msysGit安裝程序。運行到下面的頁面時,選擇“Use Git from the Windows Command Prompt”。

3. 安裝完后,需要設置Curl(目的:ensure that it can be run from the command prompt),具體設置方法參考文章【4】中的“Curl on Windows”一節。

1. 將【4】中的如下內容復制到一個新建的curl.cmd文件中,並將其保存到 msysGit的安裝路徑的cmd目錄下(比如C:\Program Files\Git\cmd\curl.cmd)。

@rem Do not use "echo off" to not affect any child calls.
@setlocal

@rem Get the abolute path to the parent directory, which is assumed to be the
@rem Git installation root.
@for /F "delims=" %%I in ("%~dp0..") do @set git_install_root=%%~fI
@set PATH=%git_install_root%\bin;%git_install_root%\mingw\bin;%PATH%

@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
@if not exist "%HOME%" @set HOME=%USERPROFILE%

@curl.exe %*

2. 在Win7命令行下運行 curl --version,如果輸出下面內容,表明curl 設置成功。

> curl --version
curl 7.21.1 (i686-pc-mingw32) libcurl/7.21.1 OpenSSL/0.9.8k zlib/1.2.3
Protocols: dict file ftp ftps http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp
Features: Largefile NTLM SSL SSPI libz

 

4. 安裝pathogen

1. Win7命令行cmd切換到 autoload 目錄下,然后執行下面的curl命令:

C:\Users\Admin\Vim\vimfiles\autoload>curl -LSso pathogen.vim https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim

NOTE: 原文中是 -Sso 選項,有錯誤,參考【5】中pdf中的修正,改為 -LSso

2. 安裝完成后,使用下面的命令查看是否能找到 pathogen.vim 文件。如果能找到,表明安裝成功。

D:\Program Files (x86)\Vim\vimfiles\autoload>dir | find /I "pathogen.vim"
2014/12/08  23:03            12,139 pathogen.vim

 

5. 修改配置_vimrc

1. 在修改_vimrc文件之前,最好先備份一下該文件。

2. 在_vimrc文件的最后添加下面的命令,使pathogen正常工作。

"Personal Settings.
"More to be added soon.
execute pathogen#infect()
filetype plugin indent on
syntax on

3. 安裝一個colorsheme插件,檢驗pathogen能否正常工作。

(1)必須確保 Win7命令行 切換到bundle 文件夾下。

(2)執行下面的命令,安裝 kolor 插件。

C:\Users\Admin\Vim\vimfiles\bundle>git clone https://github.com/zeis/vim-kolor

(3)測試kolor 插件是否安裝成功

重新打開gVim,然后輸入下面的命令,驗證gVim下的着色方案是否改變。

:colorsheme kolor

(4) 上面的命令只能在當前的gVim下起作用,關閉當前gVim窗口,再次打開后,仍是默認的colorsheme。可以在_vimrc中修改。

"Set Color Scheme
colorscheme kolor

(5)molokai的着色方案更漂亮一些,可以按照上面的步驟,使用pathogen安裝molokai插件,molokai url為https://github.com/tomasr/molokai。

C:\Users\Admin\Vim\vimfiles\bundle>git clone https://github.com/tomasr/molokai

4. 進一步設置_vimrc.

(1)可以將以下設置復制到_vimrc文件中。

"Set the status line options. Make it show more information.
set laststatus=2
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\[POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}
"Set Color Scheme and Font Options
colorscheme molokai
set guifont=Consolas:h12
"set line no, buffer, search, highlight, autoindent and more.
set nu
set hidden
set ignorecase
set incsearch
set smartcase
set showmatch
set autoindent
set ruler
set vb
set viminfo+=n$VIM/_viminfo
set noerrorbells
set showcmd
set mouse=a
set history=1000
set undolevels=1000

(2)重新打開gVim,輸入命令

:e $VIM/_vimrc

打開_vimrc文件,查看配置效果。

 

參考資料:

【1】http://www.vim.org/ugrankar.pdf

【2】ftp://ftp.vim.org/pub/vim/pc/gvim74.exe

【3】Windows下Git安裝指南(http://www.cnblogs.com/zhcncn/p/3787849.html)

【4】https://github.com/gmarik/Vundle.vim/wiki/Vundle-for-Windows

【5】vim在win7/win8系統的安裝和初步配置(http://blog.sciencenet.cn/blog-818592-829306.html)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM