强哥的vimrc大宝剑

.vimrc

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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
" vimrc begin
" Author Caiqiang Yu <ycqiangboy@gmail.com>

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Vundle and Plugin
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
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
Plugin 'VundleVim/Vundle.vim'

" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
Plugin 'scrooloose/nerdtree' "目录数
Plugin 'majutsushi/tagbar'
Plugin 'flazz/vim-colorschemes' "集成各配色主题
Plugin 'christoomey/vim-tmux-navigator' "tmux跳转工具
Plugin 'tpope/vim-surround' " 加括号加引号方便
Plugin 'benmills/vimux' "vim下得tmux
Plugin 'shawncplus/phpcomplete.vim'
Plugin 'jlanzarotta/bufexplorer' "打开历史文件列表以达到快速切换文件的目的

" vim-scripts repos
" Plugin 'taglist.vim'

" non github repos



" All of your Plugins must be added before the following line
call vundle#end() " required
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


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
syntax on
filetype plugin indent on
set incsearch " 开启实时搜索功能
set hlsearch " 高亮度搜寻
set ruler " 打开状态栏标尺
set showcmd " 显示正在输入的命令
set csto=0
set showmatch " 高亮显示匹配的括号
set guifont=Courier\ New:h10 " 设置字体
set nu " 设置行数
set t_Co=256 " 设置256色
set ff=unix " 这个文件就以 Unix 格式存盘
set tabstop=4 shiftwidth=4 softtabstop=4 expandtab " Tab键的宽度,统一缩进为4,用空格代替制表符
" 自动缩进 cindent(c风格)、smartindent(智能模式,其实不觉得有什么智能)、autoindent(简单的与上一行保持一致)
"set autoindent
set smartindent
"set cindent

" 解决插入模式下delete/backspce键失效问题
set backspace=2

"让回溯命令历史时的快捷键拥有up和down一样对历史命令进行过滤的优点
cnoremap <C-p> <Up>
cnoremap <C-n> <Down>


" vimrc文件修改之后自动加载
autocmd! bufwritepost .vimrc source %


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => F2-F12快捷键
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 去空行
" nnoremap <F2> :g/^\s*$/d<CR>
" nmap <F3> <Esc>:append<CR>var_dump($<c-r>=expand("<cword>")<CR>);exit;<CR>.<CR>:w<CR>
" " 是否显示行号切换, 方便复制
" nmap <F4> :set nonumber!<CR>:set foldcolumn=0<CR>
" nmap <F5> :tabnew<CR>
" nmap <F6> :NERDTree<CR>
" nmap <F7> <Esc>:append <CR>error_log(print_r($<c-r>=expand("<cword>")<CR>,true)."\n", 3, '/tmp/ycq.log');<CR>.<CR>:w<CR>
" nmap <F8> <ESC>:cs kill -1 <CR> <ESC>:cs add $AVATAR_HOME/project/cscope.out<CR>
" nmap <F9> <Esc>:! $AVATAR_HOME/project/create_scope.sh <CR> <ESC>:cs kill -1 <CR> <ESC>:cs add $AVATAR_HOME/project/cscope.out <CR>
" nmap <F10> :Tlist<CR>
" nmap <leader> 7 <ESC>:cs kill -1 <CR> <ESC>:cs add $AVATAR_HOME/project/cscope.out <CR>

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Learder键映射
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let mapleader=" "

nmap <leader>2 :g/^\s*$/d<CR>
nmap <leader>3 <Esc>:append<CR>var_dump($<c-r>=expand("<cword>")<CR>);exit;<CR>.<CR>:w<CR>
"是否显示行号切换, 方便复制
nmap <leader>4 :set nonumber!<CR>:set foldcolumn=0<CR>
nmap <leader>5 <ESC>:cs kill -1 <CR> <ESC>:cs add $AVATAR_HOME/project/cscope.out<CR>
nmap <leader>6 <Esc>:! $AVATAR_HOME/project/create_scope.sh <CR> <ESC>:cs kill -1 <CR> <ESC>:cs add $AVATAR_HOME/project/cscope.out <CR>
nmap <leader>7 <Esc>:append <CR>error_log(print_r($<c-r>=expand("<cword>")<CR>,true)."\n--".__LINE__."--\n", 3, '/data/webroot/ycq/tmp/my.log');<CR>.<CR>:w<CR>

nmap <leader>t :NERDTree<CR>
nmap <leader>w :w!<CR>
nmap <leader>q :qa<CR>

" 执行当前php文件
nmap <leader>r :!php %<CR>
nmap <leader>u :!phpunit %<CR>

nmap <leader>m :TagbarToggle<CR>
nmap <leader>t :NERDTree %<CR>

" 切换tab
nmap <leader>n :tabnext<CR>

" 取消高亮
nmap <leader><CR> :nohl<CR>

"对齐格式
nmap <leader>= gg=G<ESC>

" 删除所有的行尾的空格
nmap <leader>v :%s/\s\+$//<CR>:let @/=''<CR>

" 方便切换
nmap <leader>j <C-W>j
nmap <leader>k <C-W>k
nmap <leader>h <C-W>h
nmap <leader>l <C-W>l
nmap <leader>n :tabnext<CR>


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => flazz/vim-colorschemes 主题配色
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" colorscheme molokai
colorscheme desertEx
" colorscheme solarized
" colorscheme desert


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => cscope
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" s: 查找C语言符号,即查找函数名、宏、枚举值等出现的地方
" g: 查找函数、宏、枚举等定义的位置,类似ctags所提供的功能
" d: 查找本函数调用的函数
" c: 查找调用本函数的函数
" t: 查找指定的字符串
" e: 查找egrep模式,相当于egrep功能,但查找速度快多了
" f: 查找并打开文件,类似vim的find功能
" i: 查找包含本文件的文
nmap <leader>cs :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <leader>cg :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <leader>cd :cs find d <C-R>=expand("<cword>")<CR><CR>
nmap <leader>cc :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <leader>ct :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <leader>ce :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <leader>cf :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <leader>ci :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => nerdtree
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let NERDTreeMinimalUI = 0
" let NERDTreeWinPos = 'right'


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => php
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" php注释
inoremap <C-P> <ESC>:call PhpDocSingle()<CR>i
nnoremap <C-P> :call PhpDocSingle()<CR>
vnoremap <C-P> :call PhpDocRange()<CR>
" 检查php语法
autocmd FileType php noremap <C-N> :!/Data/apps/php/bin/php -l %<CR>


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => phpcomplete
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:phpcomplete_relax_static_constraint = 1




"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => TagList
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" " 设置ctags命令的位置
" let Tlist_Ctags_Cmd = '/usr/bin/ctags'
" " 设置为1时,taglist窗口横向显示。默认纵向显示
" let Tlist_Exit_OnlyWindow = 1
" " 设置taglist窗口的高度
" let Tlist_WinHeight = 100
" " 设置taglist窗口的宽度
" let Tlist_WinWidth = 40
" " 设置Tlist_Show_One_File为1则只显示当前文件的taglist,缺省显示多个文件中的tag
" let Tlist_Show_One_File = 1
" " taglish默认按tag在文件中出现的顺序进行排序,设置为"name",taglist将以tag名字进行排序
" let Tlist_Sort_Type = "name"
" " 设置为1时,如果taglist是最后一个窗口,则退出vim
" let Tlist_Exit_OnlyWindow = 1
" " 设置为1时,taglist窗口出现在右侧,缺省显示在左侧
" let Tlist_Use_Right_Window = 1
" " 如果想在启动VIM后自动打开taglist窗口,该参数设置为1
" " let Tlist_Auto_Open = 1
" " 如果想在选择了tag后自动关闭taglist窗口,该参数设置为1
" let Tlist_Close_On_Select = 1
" " 设置为1时,打开taglist光标保留在taglist窗口
" let Tlist_GainFocus_On_ToggleOpen = 1
" " taglist始终解析文件中的tag
" let Tlist_Process_File_Always = 1
" let tlist_php_settings = 'php;c:class;i:interface;d:constant;f:function'

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Tagbar
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" " 使用这个选项来指定ctags可执行文件的位置
" let g:tagbar_ctags_bin = '/usr/bin/ctags'
" " tagbar窗口宽度,默认40
" let g:tagbar_width = 30
" " 如果想在选择了tag后自动关闭taglist窗口
" let g:tagbar_autoclose = 1
" " 打开vim是自动打开
" let g:tagbar_autofocus = 1