windows 安装vim过程记录

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/pdcxs007/article/details/49668969

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目录。

猜你喜欢

转载自blog.csdn.net/pdcxs007/article/details/49668969