vim利器:vundle 管理器和NERDTree插件

vundle 和nerdtree

vundle git: https://github.com/VundleVim/Vundle.vim.git
nerdtree git : https://github.com/scrooloose/nerdtree.githtml

注意 :vundle 是一個插件管理器,咱們知道,vim的插件都在~/.vim/bundle/目錄下,只要你下載了vundle,你就能夠,利用vundle去下載別的插件了,好比: nerdtreegit

Vundle

利用Vundle 安裝NERDTree plugin
首先就是要安裝Vundlegithub

下載Vundle:

$ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

vimrc中配置Vundle

  1. 下載完畢 Vundle後,緊跟着要作的就是,修改~/.vimrc文件,將Vundle配置到vim中;
  2. 如何配置Vundle 能夠參考git幫助: https://github.com/muahao/Vundle.vim
  3. 這裏須要注意的是vundle的語法

利用Vundle安裝安裝插件

  1. 打開一個vim, 運行:BundleInstallshell

  2. 或者在命令行運行 vim +BundleInstall +qallvim

  3. 安裝完成後插件就能用了bash

vundle其它經常使用命令:

更新插件:BundleUpdate
清除再也不使用的插件:BundleClean,
列出全部插件:BundleList
查找插件:BundleSearch

nerdtree

NERDTree的做用就是列出當前路徑的目錄樹,通常IDE都是有的。能夠方便的瀏覽項目的整體的目錄結構和建立刪除重命名文件或文件名。app

安裝方法1:直接本身git clone

git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree

安裝方法2: 利用vundle

兩種安裝方法,都會在/.vim/bundle/目錄下產生一個 nerdtree目錄ui

[ahao.mah@jiangyi01.sqa.zmf /home/ahao.mah]
$ll ~/.vim/bundle/
total 20
drwxr-xr-x 13 ahao.mah users 4096 May  7 14:36 command-t
drwxr-xr-x 10 ahao.mah users 4096 May  7 14:54 nerdtree
drwxr-xr-x  6 ahao.mah users 4096 May  7 14:37 sparkup
drwxr-xr-x  5 ahao.mah users 4096 May  7 14:36 vim-fugitive
drwxr-xr-x  8 ahao.mah users 4096 May  7 14:34 Vundle.vim

使用nerdtree

報錯1: 腦殘的執行source ~/.vimrc 後,會出現bash報錯,其實緣由是這樣的,在 shell 裏不能 source vim 配置文件,vimrc的語法又不是跟shell同樣的。你改了.vimrc的內容,從新用vim打開一個文件vimrc就生效了,根本不用source,又不是shell腳本.

vim默認開啓nerdtree:

在~/.vimrc中添加this

autocmd vimenter * NERDTree

vimrc配置

$cat   ~/.vimrc
set nocompatible              " be iMproved, required
filetype off                  " required

"---------------------------------------------------------------
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
"---------------------------------------------------------------
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required

" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
" Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
 Plugin 'git://git.wincent.com/command-t.git'
 Plugin 'git://github.com/scrooloose/nerdtree.git'
 Plugin 'git://github.com/Xuyuanp/nerdtree-git-plugin.git'
" git repos on your local machine (i.e. when working on your own plugin)
" Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
" Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}

" All of your Plugins must be added before the following line
call vundle#end()            " required
"---------------------------------------------------------------
" NERDTree config
"  map <F2> :NERDTreeToggle<CR>
"   autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType")
"   &&b:NERDTreeType == "primary") | q | endif
"第一條是說使用F2鍵快速調出和隱藏它;
"第二條是關閉vim時,若是打開的文件除了NERDTree沒有其餘文件時,它自動關閉,減小屢次按:q!。
"若是想打開vim時自動打開NERDTree,能夠以下設定
autocmd vimenter * NERDTree
"---------------------------------------------------------------
filetype plugin indent on    " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList       - lists configured plugins
" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line

nerdtree-git-plugin

$git clone https://github.com/Xuyuanp/nerdtree-git-plugin.git ~/.vim/bundle/nerdtree-git-plugin

REF

http://www.cnblogs.com/lexus/archive/2012/11/04/2753187.htmlspa

http://www.xinxingzhao.com/blog/2016/05/15/vim-NERDTree.html

相關文章
相關標籤/搜索