首页 > 代码库 > 0011 vim插件的安装

0011 vim插件的安装

为了使用pathogen插件,我把.vim文件夹和.vimrc添加的配置删除,重新整理了下!

1、pathogen 插件管理
https://github.com/tpope/vim-pathogen
运行如下命令
mkdir -p ~/.vim/autoload ~/.vim/bundle
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
在.vimrc中添加
" pathogen 
execute pathogen#infect()

2、nerdtree 文件浏览器
https://github.com/scrooloose/nerdtree
运行如下命令
cd ~/.vim/bundle
git clone https://github.com/scrooloose/nerdtree.git
在.vimrc中添加
" NERDTree
map <silent> <F3> :NERDTreeToggle<CR>			" 映射F3打开关闭NERDTree

3、xptemplate 代码片段自动补全
https://github.com/drmingdrmer/xptemplate
运行如下命令
cd ~/.vim/bundle
git clone https://github.com/drmingdrmer/xptemplate.git
在.vimrc中添加
" xptemplate
let g:xptemplate_vars = "SParg=&BRfun="			" 代码紧贴括号,函数名单行
let g:xptemplate_brace_complete = "([{\""		" 括号引号自动补全	

4、emmet-vim 快速编写html和css代码 
https://github.com/mattn/emmet-vim/
运行如下命令
cd ~/.vim/bundle
git clone https://github.com/mattn/emmet-vim.git

5、nerdcommenter 为代码段添加注释
https://github.com/scrooloose/nerdcommenter
运行如下命令
cd ~/.vim/bundle
git clone https://github.com/scrooloose/nerdcommenter.git
在.vimrc中添加
" NERDcommenter
let NERDSpaceDelims = 1							" 注释左右两端留空格 
let NERDRemoveExtraSpaces = 1

6、supertab 映射ctrl+x ctrl+o用
https://github.com/ervandew/supertab
运行如下命令
cd ~/.vim/bundle
git clone https://github.com/ervandew/supertab.git
在.vimrc中添加
" supertab
let g:SuperTabDefaultCompletionType = "<C-X><C-O>"
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" 		" 回车即选中当前项

7、taglist 显示代码结构 
http://www.vim.org/scripts/script.php?script_id=273
到上面网站下载taglist,在.vim/bundle文件夹下为该插件创建文件夹,然后将其解压到创建的新文件夹中即可。
在.vimrc中添加
" Taglist
map <silent> <F4> :TlistToggle<CR>				" 映射F4打开关闭Taglist

8、更新帮助文档
插件安装完后可打开vim运行
:Helptags
命令即可更新各插件的帮助文档

9、备份我当前的.vimrc配置

" An example for a vimrc file.
"
" Maintainer:	Bram Moolenaar <Bram@vim.org>
" Last change:	2014 Feb 05
"
" To use it, copy it to
"     for Unix and OS/2:  ~/.vimrc
"	      for Amiga:  s:.vimrc
"  for MS-DOS and Win32:  $VIM\_vimrc
"	    for OpenVMS:  sys$login:.vimrc

" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
	finish
endif

" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible

" allow backspacing over everything in insert mode
set backspace=indent,eol,start

if has("vms")
	set nobackup		" do not keep a backup file, use versions instead
else
	set backup		" keep a backup file (restore to previous version)
	set undofile		" keep an undo file (undo changes after closing)
endif
set history=50		" keep 50 lines of command line history
set ruler		" show the cursor position all the time
set showcmd		" display incomplete commands
set incsearch		" do incremental searching

" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")

" Don't use Ex mode, use Q for formatting
map Q gq

" CTRL-U in insert mode deletes a lot.  Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>

" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
	set mouse=a
endif

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
	syntax on
	set hlsearch
endif

" Only do this part when compiled with support for autocommands.
if has("autocmd")

	" Enable file type detection.
	" Use the default filetype settings, so that mail gets 'tw' set to 72,
	" 'cindent' is on in C files, etc.
	" Also load indent files, to automatically do language-dependent indenting.
	filetype plugin indent on

	" Put these in an autocmd group, so that we can delete them easily.
	augroup vimrcEx
		au!

		" For all text files set 'textwidth' to 78 characters.
		autocmd FileType text setlocal textwidth=78

		" When editing a file, always jump to the last known cursor position.
		" Don't do it when the position is invalid or when inside an event handler
		" (happens when dropping a file on gvim).
		" Also don't do it when the mark is in the first line, that is the default
		" position when opening a file.
		autocmd BufReadPost *
					\ if line("'\"") > 1 && line("'\"") <= line("$") |
					\   exe "normal! g`\"" |
					\ endif

	augroup END

else

	set autoindent		" always set autoindenting on

endif " has("autocmd")

" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
	command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
				\ | wincmd p | diffthis
endif

" 一些杂项
set number
set tabstop=4
set shiftwidth=4
set autoindent
set cindent
set hlsearch
set backspace=2
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8
set timeout timeoutlen=3000 ttimeoutlen=100		"可提高输入O插入行的速度
" set cursorline									" 光标下划线

" 默认标记折叠方式
set fdm=marker		

" Ctags set
filetype plugin indent on 
set completeopt=longest,menu 

" pathogen 
execute pathogen#infect()

" NERDTree
map <silent> <F3> :NERDTreeToggle<CR>			" 映射F3打开关闭NERDTree

" Taglist
map <silent> <F4> :TlistToggle<CR>				" 映射F4打开关闭Taglist

" xptemplate
let g:xptemplate_vars = "SParg=&BRfun="			" 代码紧贴括号,函数名单行
let g:xptemplate_brace_complete = "([{\""		" 括号引号自动补全	

" NERDcommenter
let NERDSpaceDelims = 1							" 注释左右两端留空格 
let NERDRemoveExtraSpaces = 1

" Backup
set nobackup
set undodir=~/.vim/undodir

" html indent
" let g:html_indent_script1 = "inc" 
" let g:html_indent_style1 = "inc" 
let g:html_indent_inctags = "body,head,tbody" 	" 缩进body head s

" supertab
let g:SuperTabDefaultCompletionType = "<C-X><C-O>"
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" 		" 回车即选中当前项

" support html css and javascrip auto complete
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS

0011 vim插件的安装