vim插件的安裝

爲了使用pathogen插件,我把.vim文件夾和.vimrc添加的配置刪除,從新整理了下!

一、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()

二、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

三、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= &BRloop= "	" 代碼緊貼括號,函數名單行,花括號不對齊
let php_noShortTags = 1								" 禁用php短標記
" let g:xptemplate_brace_complete = "([{\""			" 括號引號自動補全,部分代碼縮進有問題	

四、emmet-vim 快速編寫html和css代碼 
https://github.com/mattn/emmet-vim/
運行以下命令
cd ~/.vim/bundle
git clone https://github.com/mattn/emmet-vim.git

五、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

六、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>" 		" 回車即選中當前項

七、taglist 顯示代碼結構 
http://www.vim.org/scripts/script.php?script_id=273
到上面網站下載taglist,在.vim/bundle文件夾下爲該插件建立文件夾,而後將其解壓到建立的新文件夾中便可。
在.vimrc中添加

" Taglist
map <silent> <F4> :TlistToggle<CR>				" 映射F4打開關閉Taglist


/* (delimitMate插件會形成gvim沒法輸入中文,我已不用,直接用xptemplate自帶的花括號補全) */
/* 八、delimitMate括號引號自動補全 */
/* https://github.com/Raimondi/delimitMate */
/* 運行以下命令 */
/* cd ~/.vim/bundle */
/* git clone https://github.com/Raimondi/delimitMate.git */
/* 在.vimrc中添加 */
/* " delimitMate 改進 */
/* inoremap <C-J> <CR><Esc>O */

/* 這樣按ctrl+j快捷鍵就能自動縮排自動補全的花括號了,該插件提供的delimitMate_expand_cr 參數我沒有成功,只好本身建立一個 */


九、更新幫助文檔
插件安裝完後可打開vim運行
:Helptags
命令便可更新各插件的幫助文檔

十、備份我當前的.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 softtabstop=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							" 默認標記摺疊方式

" pathogen 
execute pathogen#infect()

" omni complete
filetype plugin on
set ofu=syntaxcomplete#Complete
set completeopt=longest,menu 

" supertab
let g:SuperTabDefaultCompletionType = "<C-X><C-O>"
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" 		" 回車即選中當前項

" NERDTree
map <silent> <F3> :NERDTreeToggle<CR>				" 映射F3打開關閉NERDTree

" Taglist
map <silent> <F4> :TlistToggle<CR>				" 映射F4打開關閉Taglist

" xptemplate
let g:xptemplate_vars = "SParg=&BRfun= &BRloop= "	<span style="white-space:pre">	</span>" 代碼緊貼括號,函數名單行,花括號不對齊
let php_noShortTags = 1						" 禁用php短標記
" let g:xptemplate_brace_complete = "([{\""			" 括號引號自動補全,部分代碼縮進有問題	

" NERDcommenter
let NERDSpaceDelims = 1						" 註釋左右兩端留空格 
let NERDRemoveExtraSpaces = 1

" Backup
set backupdir=~/.vim/backup					" vim備份的文件夾
set undodir=~/.vim/undo						" vim撤銷記錄文件夾

" html indent
" let g:html_indent_script1 = "inc"				" 縮進<script>標籤
let g:html_indent_style1 = "inc"				" 縮進<style>標籤
let g:html_indent_inctags = "body,head,tbody"			" 縮進body head
相關文章
相關標籤/搜索