Matthew Note

Vim on OSX

Quick Start

已经实现了一个非常基本的自动化脚本,可以输入如下命令进行自动化安装,如果是OSX,需要提前安装brew:

1
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

之后运行:

1
wget -qO- https://raw.github.com/matthewgao/MyVim/master/setup.sh | sh

当所有安装完成,就得到了一个包含如下插件的Vim:

  • Bundle
  • FuzzyFinder
  • L9
  • tagslist
  • ctags
  • NERDtree
  • NERD-Commenter
  • Auto-pair
  • Ctrlp
  • ctrlp-funky
  • airline
  • powerline
  • translate
  • vim chinese doc
  • calendar
  • molokai colorscheme

项目托管在github上 MyVim

自动安装包含如下过程:

  • 检查系统,yum or apt-get or brew
  • 安装组件
  • 安装MyVim
  • 复制vim到.vim
  • 复制vimrc到.vimrc
  • 安装Bundle
  • 执行BundleInstall

Powerline font

1
2
git clone https://github.com/powerline/fonts.git
fonts/install.sh

##安装中文Help doc

下载vimdoc包猛击下载,下载的 tar.gz 包括所有翻译过的 vim 文档 (.cnx 文件) 先将其解压缩:

1
tar zxvf vimcdoc-<version>.tar.gz

然后进入 vimcdoc- 目录并执行

1
./vimcdoc.sh -i

就可以了。该安装程序会自动识别 Vim 的安装路径,将中文的文档拷贝 到相应的地方。原有的英文文档不受影响。

插件简介

NERDtree

在nerdtree窗口常用操作:

1
2
3
4
5
6
7
8
9
10
x.......Close the current nodes parent收起当前目录树
R.......Recursively refresh the current root刷新根目录树
r.......Recursively refresh the current directory刷新当前目录
P.......Jump to the root node
p.......Jump to current nodes parent
K.......Jump up inside directories at the current tree depth 到同目录第一个节点
J.......Jump down inside directories at the current tree depth 最后一个节点
o.......Open files, directories and bookmarks
i.......Open selected file in a split window上下分屏
s.......Open selected file in a new vsplit左右分屏

配置解析

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
set nocompatible " be iMproved
set shell=/bin/sh
set tabstop=4
set softtabstop=4
set shiftwidth=4
" FIXME
set expandtab
set autoindent
set nu
set ruler
colorscheme molokai
set showcmd
" 高亮搜索
set hlsearch
" 跟随搜索
set incsearch
set mouse=a
set linebreak
set mousemodel=popup
set autowrite
set cmdheight=2
" 去掉输入错的提示音
set noeb
set ignorecase
set wildmenu
"FIXME 允许backspace和光标跨越行边界
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
set linespace=0
set wildmenu
set completeopt=preview,menu
set completeopt=longest,menu "tab替换成空格
if version>=603
set helplang=cn
set encoding=utf-8
endif
filetype on
filetype plugin on
filetype plugin indent on " required!
syntax on
syntax enable
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
"这是vundle本身的设置
Bundle 'gmarik/vundle'
" My Bundles here:
"这里是设置你自己自定义的插件的设置vundle设置,注意:下载
"的插件git为:https://github.com/godlygeek/tabular.git,则设置为Bundle
"'godlygeek/tabular';https://github.com/gmarik/vundle.git设置则为
" Bundle 'gmarik/vundle'
" original repos on github
Bundle 'godlygeek/tabular'
" vim-scripts repos,vim-scripts的访问地址,格式则如下:
Bundle 'L9'
Bundle 'FuzzyFinder'
" non github repos ,非git的访问地址的,格式如下:
Bundle 'git://git.wincent.com/command-t.git'
Bundle 'Auto-Pairs'
Bundle 'The-NERD-Commenter'
"Bundle 'ctrlp.vim'
Plugin 'ctrlp.vim'
Plugin 'scrooloose/nerdtree'
"
" 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..
nmap tt :%s/\t/ /g<CR>
map <F3> :NERDTreeToggle<CR>
imap <F3> <ESC> :NERDTreeToggle<CR>
map <silent> <F9> :TlistToggle <CR>
let Tlist_Auto_Open=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Use_Right_Window=1
let NERDTreeIgnore=['\.pyc']
" crtlp setting
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.png,*.jpg,*.gif " Mac/Linux