windows 安裝vim過程記錄

windows 安裝vim過程記錄

下載安裝文件

在網站http://www.vim.org/download.php下載。

文件編碼問題

在_vimrc中,輸入:

"the chinese encoding
set encoding=utf-8
set fileencodings=utf-8,chinese,latin-1
if has("win32")
    set fileencoding=chinese
else
    set fileencoding=utf-8
endif
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
language messages zh_CN.utf-8
set termencoding=gbk

OK,這樣gvim和命令行的vim顯示均正常。

字體設置

英文采用Inconsolata字體,中文采用微軟雅黑(YaHei_mono.ttf)。安裝好字體後,在vimrc中加入:

" The fonts
set guifont="Inconsolata 20"
set gfw=Yahei_Mono:h10.5:cGB231

設置基本的配置文件內容

set history=400
set tabstop=8
set nobackup
set softtabstop=4
set shiftwidth=4
set expandtab
set nu
set wildmenu
set wildmode=full
"colorscheme desert
syntax enable
set background=dark
set foldenable
set nocompatible
set completeopt=longest,menu
set autoindent
set autochdir
set magic
set cursorline
set cursorcolumn
set syntax=on
set cindent
set guioptions-=T
set guioptions-=r
set guioptions+=c
set guioptions-=L
filetype plugin indent on
filetype plugin on

"F4 to toggle highlighting on/off
noremap <F4> :set hlsearch! hlsearch?<CR>
"F3 to toggle caseinsensetive
noremap <F3> :set ic! ic?<CR>

Pathogen插件安裝

此插件可用於管理其它插件。
下載地址:http://www.vim.org/scripts/script.php?script_id=2332
安裝方法見官方網站。記錄:
將pathogen.vim拷貝至vimfiles/autoload文件夾下(autoload文件夾需手動創建)
在vimrc中添加:

execute pathogen#infect()

Solarized 配色方案

從網站https://github.com/altercation/vim-colors-solarized下載所有的文件
將zip移動到vimfires/bundle文件夾(需要手動創建),並在此解壓。
在vimrc中加入:

colorscheme solarized
let g:solarized_italic=(abs(g:solarized_italic-1)) | colorscheme solarized

第二行用於關閉斜體顯示。斜體在Windows中顯示不正常。

安裝Ctags

下載Ctags,解壓,添加至PATH變量即可。
vimrc中加入:

map <C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>:set tags+=tags<CR>

安裝Taglist插件

下載http://www.vim.org/scripts/script.php?script_id=273
將文件拷貝到vimfires/bundle/taglist並解壓到此目錄。
在vimrc中加入:

let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1

安裝OmniCppComplete

下載http://www.vim.org/scripts/script.php?script_id=1520
解壓到vimfiles/bundle/omnicppcomplete
vimrc中加入

set nocp
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
let OmniCpp_NamespaceSearch = 2
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_MayCompleteDot = 1
let OmniCpp_MayCompleteArrow = 1
let OmniCpp_MayCompleteScope = 1
let OmniCpp_SelectFirstItem = 2
let OmniCpp_DefaultNamespaces = ["std", "GLIBCXX_STD"]

安裝SuperTab

下載:http://www.vim.org/scripts/script.php?script_id=1643

用vim打開vmb文件,輸入:so %,即安裝成功。
vimrc中加入:

let g:SuperTabDefaultCompletionType="context"

安裝NERDTree

下載:http://www.vim.org/scripts/script.php?script_id=1658
解壓至vimfires/bundle/nerdtree

安裝Winmanager

下載:http://www.vim.org/scripts/script.php?script_id=95
解壓到vimfiles/bundle/winmanager
vimrc中加入:

let g:NERDTree_title="[NERDTree]"
let g:winManagerWindowLayout="NERDTree|TagList"

function! NERDTree_Start()
    exec 'NERDTree'
endfunction

function! NERDTree_IsValid()
    return 1
endfunction

"nmap wm :WMToggle<CR>

注意最好不要map wm,因爲這會導致單詞移動指令w很慢,而這個指令是很常用的。
這個版本的winmanager要打開窗口時會又打開一個小窗口。修正:
打開plugin/winmanager.vim
找到函數ToogleWindowsManager,並添加exe 'q',即改爲如下形式:

function! <SID>ToggleWindowsManager()
    if IsWinManagerVisible()
        call s:CloseWindowsManager()
    else
        call s:StartWindowsManager()
        exe 'q'
    end
endfunction

安裝MiniBufExplorer

下載:http://www.vim.org/scripts/script.php?script_id=159
將minibufexpl.vim拷貝到vimfiles/plugin中
vimrc中加入:

let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1
let g:minBufExplMoreThanOne=0

C++文件的自動加載STL tags

vimrc:

autocmd FileType cpp set tags+=d:\software\tags\stdcpp.tags

安裝javacomplete

下載:http://www.vim.org/scripts/script.php?script_id=1785
解壓至vimfiles/bundle/javacomplete
vimrc:

autocmd Filetype java setlocal omnifunc=javacomplete#Complete

第一次運行會有點慢,因爲要編譯Reflection.java。以後就好了。

STL語法高亮

下載:http://www.vim.org/scripts/script.php?script_id=4293
將stl.vim拷貝到vimfiles/after/syntax/cpp文件夾中,沒有此路徑就手動創建。

Python Complete

下載http://www.vim.org/scripts/script.php?script_id=1542
將pythoncomplete.vim複製到vimfiles/autoload中

Python語法高亮強化

下載:http://www.vim.org/scripts/script.php?script_id=790
得到python.vim到vimfiles/syntax下。

windows 全屏

下載http://www.vim.org/scripts/script.php?script_id=2596#1.0
將dll文件放在和gvim.exe一個目錄下。在vimrc中加入:

autocmd VimEnter * call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)
map <F11> <Esc>:call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)<CR>

其中,第一行的作用是啓動就全屏。第二行的作用是按F11全屏。

安裝html

下載http://www.vim.org/scripts/script.php?script_id=453
解壓至bundle目錄下的HTML文件夾。
在HTML文件夾下新建一個template文件夾,裏面加入template.html,內容如下:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8" />
    <title>This is a test</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1" />
</head>
<body>

</body>

在vimrc中加入:

autocmd Filetype html set guioptions-=T
let g:html_template = 'F:\mytools\vim\vimfiles\bundle\HTML\template\template.html'
let g:no_html_tab_mapping = 'yes'

其中第一句是因爲html插件會在工具欄中加入內容,導致顯示不正常。需要再次去掉工具欄並按回車確認錯誤並繼續。第二句是指向template.html文件。第三行避免則是HTML.vim的TAB和supertab.vim衝突。可以在html文件的決普通模式下,輸入;html試試。

安裝css_color

下載:http://www.vim.org/scripts/script.php?script_id=2150
將css.vim保存至vimfiles/aftwr/syntax/css.vim
現在css就可以顯示顏色了。

安裝AutoComplPop

下載:http://www.vim.org/scripts/script.php?script_id=1879

javascript語法高亮

下載http://www.vim.org/scripts/script.php?script_id=1491
將javascript.vim移動至vimfiles/syntax中

jspc.vim : JavaScript Parameter Complete

下載https://github.com/othree/jspc.vim
解壓至bundle目錄即可

安裝tern for vim

下載:https://github.com/marijnh/tern_for_vim
在其目錄下運行npm install(需要安裝好nodejs)

安裝前端神器Emmet

下載https://github.com/mattn/emmet-vim
解壓至bundle目錄即可。

使用Linux模式

將vim74目錄下的mswin.vim重命名爲其它名字,將_vimrc中的兩行註釋掉:

"source $VIMRUNTIME/mswin.vim
"behave mswin

在默認的配置文件中,應該是3、4行

現在就可以使用<C-a><C-x><C-v>等鍵了。

安裝the better javascript completion

下載https://github.com/1995eaton/vim-better-javascript-completion
解壓至bundle目錄即可。

安裝easy-motion

下載http://www.vim.org/scripts/script.php?script_id=3526
解壓至bundle目錄即可。

安裝vim-surround

下載https://github.com/tpope/vim-surround
解壓至bundle目錄。

安裝nerdcommenter

下載https://github.com/scrooloose/nerdcommenter
解壓至bundle目錄。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章