-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
233 lines (207 loc) · 8.5 KB
/
Copy pathvimrc
File metadata and controls
233 lines (207 loc) · 8.5 KB
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
"---------------------------------------------------------------------------
" NeoBundle
"---------------------------------------------------------------------------
" http://www.erikzaadi.com/2012/03/19/auto-installing-vundle-from-your-vimrc/
" Setting up Vundle - the vim plugin bundler
let neobundle_readme=expand('~/.vim/bundle/neobundle.vim/README.md')
if !filereadable(neobundle_readme)
echo "Installing Vundle.."
echo ""
silent !mkdir -p ~/.vim/bundle
silent !git clone https://github.com/Shougo/neobundle.vim.git ~/.vim/bundle/neobundle.vim
endif
if has('vim_starting')
set nocompatible
set runtimepath+=~/.vim/bundle/neobundle.vim/
endif
call neobundle#begin(expand('~/.vim/bundle/'))
" Let NeoBundle manage NeoBundle
NeoBundleFetch 'Shougo/neobundle.vim'
" My Bundles here:
"NeoBundle 'vim-scripts/AutoComplPop' "字詞補完
NeoBundle 'Shougo/neocomplcache.vim' "字詞補完,查找專案內的檔案
"NeoBundle 'Shougo/neocomplete.vim' "字詞補完 新版
NeoBundle 'scrooloose/nerdtree' "檔案總管
NeoBundle 'dyng/ctrlsf.vim' "類似sublime text ctrlp+shift+f
NeoBundle 'jlanzarotta/bufexplorer' "開啟的檔案切換 \be \bs \bv
NeoBundle 'kien/ctrlp.vim' "快速搜尋檔案名稱
NeoBundle 'vim-scripts/taglist.vim' "function tag list
NeoBundle 'bling/vim-airline' "下面狀態列
NeoBundle 'c9s/colorselector.vim' "配色選擇器 SelectColorS, EditCurrentColorS
NeoBundle 'ap/vim-css-color' "CSS 顏色顯示
NeoBundle 'vim-scripts/Visual-Mark' "書籤功能, <F2> Ctrl+<F2> Shift+<F2>
NeoBundle 'jiangmiao/auto-pairs' "括號補全
NeoBundle 'othree/xml.vim' "tag補全,包含HTML
NeoBundle 'xolox/vim-misc' "暫存最後修改資料
NeoBundle 'xolox/vim-session' "暫存最後修改資料
NeoBundle 'rkulla/pydiction' "python 語法補完 tab
NeoBundle 'vim-scripts/php.vim' "php 語法補完
NeoBundle 'scrooloose/syntastic' "語法檢查
" You can specify revision/branch/tag.
"NeoBundle 'Shougo/vimshell', { 'rev' : '3787e5' }
call neobundle#end()
" this will conveniently prompt you to install them.
NeoBundleCheck
"NeoBundleUpdate
"---------------------------------------------------------------------------
" Encoding
"---------------------------------------------------------------------------
set encoding=utf-8
set termencoding=utf-8
set fileencoding=utf-8
set fileencodings=ucs-bom,utf-8,big5,gb2312,latin1
"---------------------------------------------------------------------------
" Theme
"---------------------------------------------------------------------------
if has('gui_running')
"Gvim
"colorscheme wombat256mod
colorscheme Tomorrow-Night
set guifont=Monaco\ 11
set guioptions=m "關閉功能列
else
"Vim
"colorscheme zenburn
"colorscheme obsidian
colorscheme Tomorrow-Night
set guifont=Monaco:h11
set t_Co=256
endif
"---------------------------------------------------------------------------
" Tab and Spacebar
"---------------------------------------------------------------------------
set list
set listchars=tab:>_,trail:.
set shiftwidth=4 " 縮排空白數,要搭配set cin使用
set softtabstop=4
set tabstop=4 " tab使用空白取代
set noexpandtab
set smartindent
"---------------------------------------------------------------------------
" Folding
"---------------------------------------------------------------------------
set foldenable
set foldmethod=syntax
set foldcolumn=0
"---------------------------------------------------------------------------
" Other
"---------------------------------------------------------------------------
filetype plugin indent on "文件类型检测,自動判斷要載入的語法補完
syntax on
set autoread "正在編輯文件被其它程序改動時reload
set autoindent "设置自动对齐(缩进):即每行的缩进值与上一行相等;使用 noautoindent 取消设置
set smartindent "智能对齐方式
"set cindent "使用 C/C++ 语言的自动缩进方式
"set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s " 设置C/C++语言的具体缩进方式
set wrap "自动换行
set linebreak "整词换行
set mouse=vn
"set number "行號
set cursorline "游標水平線
"set cursorcolumn "游標重直線
"set colorcolumn=80
set textwidth=0
set backspace=2 "按下backspace會後退,道行首後會刪除到前一行
set showmatch "顯示括號配對情況
set nocompatible "用vim的特性去運行,捨棄vi的特性
set hlsearch "搜尋反白
set incsearch "搜尋即時查找
set ignorecase "搜尋不分大小寫
set history=9999
set clipboard=unnamedplus "同步剪貼簿,相關套件 sudo apt-get install vim-gtk
"---------------------------------------------------------------------------
" Shortcuts
"---------------------------------------------------------------------------
map<F3> :call SearchWord()<CR>
map<F4> :q<CR>
map<F5> :NERDTreeToggle<CR>
map<F6> :TlistToggle<CR>
map <leader>il :IndentLinesToggle<CR>
set pastetoggle=<F12> "縮排快速開關,貼上文字時使用,防止自動縮排
"set keywordprg=sdcv
"---------------------------------------------------------------------------
" statusline
"---------------------------------------------------------------------------
set laststatus=2
"set statusline=%4*%<\ %1*[%F]
"set statusline+=%4*\ %5*[%{&encoding}, " encoding
"set statusline+=%{&fileformat}%{\"\".((exists(\"+bomb\")\ &&\ &bomb)?\",BOM\":\"\").\"\"}]%m
"set statusline+=%4*%=\ %6*%y%4*\ %3*%l%4*,\ %3*%c%4*\ \<\ %2*%P%4*\ \>
"highlight User1 ctermfg=red
"highlight User2 term=underline cterm=underline ctermfg=green
"highlight User3 term=underline cterm=underline ctermfg=yellow
"highlight User4 term=underline cterm=underline ctermfg=white
"highlight User5 ctermfg=cyan
"highlight User6 ctermfg=white
"---------------------------------------------------------------------------
" package settings
"---------------------------------------------------------------------------
"neocomplcache
let g:neocomplcache_enable_at_startup = 1
"let g:neocomplcache_enable_smart_case = 2
"pydiction
let g:pydiction_location = '~/.vim/bundle/pydiction/complete-dict'
let g:pydiction_menu_height = 12
"NERDTree
let NERDTreeIgnore = ['\.pyc$']
"taglist
let Tlist_Use_Right_Window = 1
let Tlist_Show_One_File = 1 "只顯示當前檔案
let Tlist_Exit_OnlyWindow = 1 "如果taglist是最後窗口,直接關閉vim
if(has("win32") || has("win64"))
let Tlist_Ctags_Cmd = expand('~/.vim/ctags.exe')
endif
"ctrlp
let g:ctrlp_clear_cache_on_exit = 0 "離開 vim 後不要清 cache
let g:ctrlp_max_files = 10000 "加大 cache 索引的檔案數, 否則會漏找檔案
let g:ctrlp_user_command = 'find %s -type f' "使用 find 加速建索引的速度
"session
let g:session_autosave = 'no'
"let g:session_autoload = 'yes'
"AirLine
let g:airline_theme = 'murmur'
let g:airline_powerline_fonts = 0
let g:airline_left_sep = ''
let g:airline_right_sep = ''
let g:airline#extensions#tabline#enabled = 0 "不顯示buffers
let g:airline#extensions#tabline#left_sep = ''
let g:airline#extensions#tabline#left_alt_sep = '|'
"scrooloose/syntastic
let g:syntastic_check_on_open = 1
let g:syntastic_aggregate_errors = 1
let g:syntastic_php_checkers = ['php', 'phpcs', 'phpmd']
let g:syntastic_python_checkers = ['pyflakes', 'pep8']
"---------------------------------------------------------------------------
" 開啟跟存檔時執行
"---------------------------------------------------------------------------
" 開啟檔案時停留在上次開啟的行數
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g'\"" | endif
endif
" 存檔時刪除多餘空白 tab
autocmd BufWritePre * call RemoveTrailingWhitespace()
"---------------------------------------------------------------------------
" function
"---------------------------------------------------------------------------
function! SearchWord()
let expl=system('sdcv -n ' .
\ expand("<cword>"))
windo if
\ expand("%")=="diCt-tmp" |
\ q!|endif
10sp diCt-tmp
setlocal buftype=nofile bufhidden=hide noswapfile
1s/^/\=expl/
1
endfunction
" Remove trailing whitespace when writing a buffer, but not for diff files.
function! RemoveTrailingWhitespace()
if &ft != "diff"
let b:curcol = col(".")
let b:curline = line(".")
silent! %s/\s\+$//
silent! %s/\(\s*\n\)\+\%$//
call cursor(b:curline, b:curcol)
endif
endfunction