-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
200 lines (169 loc) · 4.81 KB
/
.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
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
runtime bundle/vim-pathogen/autoload/pathogen.vim
call pathogen#infect()
filetype on
filetype indent on
filetype plugin on
syntax on
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
set laststatus=2 " Always show the statusline
set nu
set bs=2
set history=1000
set ruler
set autoread
set showcmd " display incomplete commands
set incsearch " do incremental searching
set autoindent
set copyindent
set ignorecase
set smartcase
set smarttab
set hlsearch " search highlighting
set clipboard+=unnamed
set formatoptions=tcrqn
set mouse=nv
autocmd! bufwritepost .vimrc source ~/.vimrc
"if has("gui_running")
"colorscheme oceandeep
colorscheme molokai
"colorscheme wombat256mod
"colorscheme asmanian_blood
"colorscheme desert
"colorscheme gentooish
set linespace=3
set t_Co=256 " 256 color mode
set cursorline " hightlight current line
"endif
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file
endif
" Don't use Ex mode, use Q for formatting
map Q gq
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
map <silent> <F2> :NERDTreeToggle<CR>
map <silent> <F3> :TlistToggle<CR>
" TAB setting {
set expandtab "replace <TAB> with spaces
set softtabstop=4
set shiftwidth=4
au FileType Makefile set noexpandtab
"}
"
"Restore cursor to file position in previous editing session
set viminfo='10,\"100,:20,%,n~/.viminfo
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
" set leader to ,
let mapleader=","
let g:mapleader=","
" --- superTab
let g:SuperTabDefaultCompletionType="context"
let g:SuperTabCompletionContexts=['s:ContextText', 's:ContextDiscover']
" --- Command-T
let g:CommandTMaxHeight=15
" --- AutoClose
"if !has("gui_running")
" set term=linux
imap OA <ESC>ki
imap OB <ESC>ji
imap OC <ESC>li
imap OD <ESC>hi
nmap OA k
nmap OB j
nmap OC l
nmap OD h
"endif
" ---ctags
set tags=~/.vim/tags
set tags+=tags
" ---cscope
if has("cscope")
set cscopequickfix=s-,c-,d-,i-,t-,e-
set csto=0
set cst
set csverb
endif
" --- clang_complete
"let g:clang_snippets=1
"let g:clang_snippets_engine='snipmate'
let g:clean_complete_auto = 0
let g:clang_complete_copen = 1
let g:clang_use_library = 1
let g:clang_libary_path = "/usr/lib"
set completeopt=menu,longest
" ENCODING SETTING
set encoding=utf-8
set termencoding=utf-8
set fileencoding=utf-8
set fileencodings=ucs-bom,utf-8,big5,gb2312,latin1
" QUICKFIX WINDOW
command -bang -nargs=? QFix call QFixToggle(<bang>0)
function! QFixToggle(forced)
if exists("g:qfix_win") && a:forced == 0
cclose
unlet g:qfix_win
else
copen 10
let g:qfix_win = bufnr("$")
endif
endfunction
map <silent> <F4> :QFix <CR>
map <silent> <F5> :make <CR>
map <silent> <F7> :Grep <CR>
map <silent> <F8> :call Do_CsTag()<CR>
function Do_CsTag()
let dir = getcwd()
if filereadable("tags")
let tagsdeleted=delete("./"."tags")
if(tagsdeleted!=0)
echohl WarningMsg | echo "Fail to do tags! I cannot delete the tags" | echohl None
return
endif
endif
if has("cscope")
silent! execute "cs kill -1"
endif
if filereadable("cscope.files")
let csfilesdeleted=delete("./"."cscope.files")
if(csfilesdeleted!=0)
echohl WarningMsg | echo "Fail to do cscope! I cannot delete the cscope.files" | echohl None
return
endif
endif
if filereadable("cscope.out")
let csoutdeleted=delete("./"."cscope.out")
if(csoutdeleted!=0)
echohl WarningMsg | echo "Fail to do cscope! I cannot delete the cscope.out" | echohl None
return
endif
endif
if(executable('ctags'))
silent! execute "!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ."
endif
if(executable('cscope') && has("cscope"))
silent! execute "!find . -name '*.h' -o -name '*.c' -o -name '*.cpp' > cscope.files"
silent! execute "!cscope -b"
execute "normal :"
if filereadable("cscope.out")
execute "cs add cscope.out"
endif
endif
endfunction