Wednesday, September 14, 2016

install nerdtree with vbundle for vim

1. preparation

    touch ~/.vimrc
    mkdir~/.vim/bundle

2. install vbundle

git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
 

3. add the following to .vimrc

set nocompatible               " be iMproved
filetype off                   " required!

set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

" let Vundle manage Vundle
" required! 
Bundle 'gmarik/vundle'

" My Bundles here:

filetype plugin indent on     " required!
"
" Brief help
" :BundleList          - list configured bundles
" :BundleInstall(!)    - install(update) bundles
" :BundleSearch(!) foo - search(or refresh cache first) for foo
" :BundleClean(!)      - confirm(or auto-approve) removal of unused bundles
"
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Bundle command are not allowed.. 
 
 

4. install NERDTree, add the bundle name to .vimrc


call vundle#begin()

     
Bundle 'scrooloose/nerdtree'

call vundle#end()  



 5. re-launch vi, and type the :BundleInstall command to install the nerdtree.


6.  verify able to launch nerdtree, by typing ":NERDTree" . Note that the command is sensitive.

7. create hotkey  F2 for NERDTRee:  add below line to .vimrc.

 
 

 
some commands I learned easilly:
 
ctr+w+h  光标移到左侧树形目录,
ctrl+w+l 光标移到右侧文件显示窗口
ctrl + w + w    光标自动在左右侧窗口切换
 
   o 打开关闭文件或者目录

   t 在标签页中打开

  T 在后台标签页中打开

  ! 执行此文件

  p 到上层目录

  P 到根目录

  K 到第一个节点

  J 到最后一个节点
 k  previous
j  next 
  

tabs commands are what I am thinking to google,but already there.

:tabnew [++opt选项] [+cmd] 文件      建立对指定文件新的tab
:tabc   关闭当前的 tab
:tabo   关闭所有其他的 tab
:tabs   查看所有打开的 tab
:tabp   前一个 tab
:tabn   后一个 tab
 
 
 
and more to practice noted below.


ctrl + w + r    移动当前窗口的布局位置
go      在已有窗口 中打开文件、目录或书签,但不跳到该窗口
i       split 一个新窗口打开选中文件,并跳到该窗口
gi      split 一个新窗口打开选中文件,但不跳到该窗口
s       vsplit 一个新窗口打开选中文件,并跳到该窗口
gs      vsplit 一个新 窗口打开选中文件,但不跳到该窗口
!       执行当前文件
O       递归打开选中 结点下的所有目录
x       合拢选中结点的父目录
X       递归 合拢选中结点下的所有目录
e       Edit the current dif
双击    相当于 NERDTree-o
中键    对文件相当于 NERDTree-i,对目录相当于 NERDTree-e
D       删除当前书签
C       将选中目录或选中文件的父目录设为根结点
u       将当前根结点的父目录设为根目录,并变成合拢原根结点
U       将当前根结点的父目录设为根目录,但保持展开原根结点
r       递归刷新选中目录
R       递归刷新根结点
m       显示文件系统菜单
cd      将 CWD 设为选中目录
I       切换是否显示隐藏文件
f       切换是否使用文件过滤器
F       切换是否显示文件
B       切换是否显示书签
 

also reviewed commands to execute external commands.

:shell or just :sh  or Ctrl-z  and fg


:r textfile
:r ! ls -1 /home/user/directory


Installation on cygwin

Followed this article, I easily installed NERDTree  to the vim.

https://my.oschina.net/VASKS/blog/388907


Installed more bundle from  http://www.zlovezl.cn/articles/vim-plugins-cannot-live-without/


In short time, I built up my own .vimrc as shown below.

hmc@hmc-P55A-UD3:~$ cat .vimrc
syntax enable
syntax on
set nocompatible              " be iMproved, required
filetype off                  " required

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

   
Bundle 'scrooloose/nerdtree'
Bundle 'jistr/vim-nerdtree-tabs'
Bundle 'scrooloose/syntastic'
Bundle 'Valloric/YouCompleteMe'
Bundle 'vim-airline/vim-airline'
Bundle 'chriskempson/base16-vim'
Bundle 'majutsushi/tagbar'

call vundle#end()            " required
filetype plugin indent on    " required

nmap :NERDTreeToggle
let g:nerdtree_tabs_open_on_console_startup=1
map n NERDTreeTabsToggle


" for YCM

" 设置跳转到方法/函数定义的快捷键
 nnoremap j :YcmCompleter GoToDefinitionElseDeclaration
 " 触发补全快捷键
let g:ycm_key_list_select_completion = ['', '', '']
let g:ycm_key_list_previous_completion = ['', '', '']
let g:ycm_auto_trigger = 1
" 最小自动触发补全的字符大小设置为 3
let g:ycm_min_num_of_chars_for_completion = 3
" YCM的previw窗口比较恼人,还是关闭比较好
set completeopt-=preview




References:



http://williamherry.com/blog/2012/07/16/master-vim-01-vundle/
http://williamherry.com/blog/2012/07/19/master-vim-02-nerdtree/

https://my.oschina.net/VASKS/blog/388907
https://www.linux.com/learn/vim-tips-working-external-commands
http://os.51cto.com/art/201507/484174.htm

http://blog.csdn.net/namecyf/article/details/7787479