-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
307 lines (292 loc) · 8.82 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
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
" << FROM PANGU - BEGIN - >>
set nocompatible " This must be first, because it changes other options as a side effect.
set backspace=indent,eol,start " allow backspacing over everything in insert mode
map Q gq " Don't use Ex mode, use Q for formatting
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
if has("autocmd")
filetype plugin indent on
augroup vimrcEx
au!
autocmd FileType text setlocal textwidth=78
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
au BufRead,BufNewFile *.txt setlocal ft=txt
hi StatusLine ctermfg=Magenta ctermbg=Yellow
hi StatusLineNC term=reverse ctermfg=Gray ctermbg=Black
hi TabLine ctermfg=Blue ctermbg=Gray
hi TabLineSel ctermfg=Black ctermbg=DarkCyan
hi TabLineFill ctermfg=Gray ctermbg=Black
hi LineNr ctermfg=darkgray
set <F1>=[11;*~
set <F2>=[12;*~
set <F3>=[13;*~
set <F4>=[14;*~
set <S-Tab>=[Z
"set encoding=utf-8
"set termencoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8,latin1,utf-16le,prc
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
set nobackup
set autoread
set ff=unix
set ffs=unix
set nowb
set nowrap
set fileformat=unix
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set cinoptions=:0,g0
set autowrite
set splitbelow
set hidden
set vb t_vb=
set background=dark
set wildmode=list:longest
set laststatus=2
set statusline=[%l,%L]\ %P\ %<%f\ %h%m%r%=%(c=%c%V%)
set smartindent
if has("autocmd")
autocmd FileType c call CDetected()
autocmd FileType perl call PerlDetected()
autocmd FileType cpp call CppDetected()
autocmd FileType php call PhpDetected()
autocmd FileType ruby call RubyDetected()
endif
"+----------------------------------------------------------+
"| General Settings |
"| -END- |
"+----------------------------------------------------------+
"===============================================================================
"+----------------------------------------------------------+
"| Key Mappings |
"+----------------------------------------------------------+
map ,q :q<CR>
nnoremap <Tab> gt
nnoremap <S-Tab> :tab split<CR>
nnoremap <Space> gT
nnoremap <silent> <Left> :bp<CR>
nnoremap <silent> <Right> :bn<CR>
nnoremap <C-Up> :cp<CR>
nnoremap <C-Down> :cn<CR>
nnoremap <C-J> <C-W>j
nnoremap <C-K> <C-W>k
nnoremap <C-H> <C-W>h
nnoremap <C-L> <C-W>l
nnoremap <F3> [I
nnoremap <silent> <F5> :colorscheme murphy<CR>
nnoremap <silent> <F4> :bd<CR>
nnoremap <silent> <F6> :call ToggleSketch()<CR>
nnoremap <silent> <F7> :WMToggle<CR>
nnoremap <silent> <F8> :Tlist<CR>
nnoremap t :tags<CR>
nnoremap T :tag<CR>
nnoremap <C-N> :tab new
map ,ba <C-W>_zz<C-W><Bar>zz
map ,bb :e #<CR>
map ,bm <C-W>=
map ,bt <C-W>}
map ,bn :ptn<CR>
map ,bp :ptp<CR>
map ,bc :pc<CR>
map ,< <C-W>20<
map ,> <C-W>20>
nnoremap x "_x
nnoremap dw "_dw
nnoremap <UP> 5<C-W>+
nnoremap <DOWN> 5<C-W>-
"+----------------------------------------------------------+
"| Key Mappings |
"| -END- |
"+----------------------------------------------------------+
"===============================================================================
"+----------------------------------------------------------+
"| My Own Functions |
"+----------------------------------------------------------+
function CDetected()
map ,g :call <SID>CompileCForDebug()<CR>
map ,d :call <SID>DebugCFile()<CR>
map ,e :call <SID>RunCFile()<CR>
setlocal textwidth=80
set tags+=~/.vim/sys_basic_tags
set tags+=~/local/include/tags
endfunction
function RubyDetected()
set tabstop=2
set shiftwidth=2
set softtabstop=2
hi rubyFunction term=bold ctermfg=Red ctermbg=Gray
hi rubyComment term=bold ctermfg=darkgray
endfunction
function PerlDetected()
map ,e :call <SID>RunPerlFile()<CR>
map ,d :call <SID>DebugPerlFile()<CR>
setlocal cpt=.,w,b,u,t
hi perlComment term=bold ctermfg=DarkCyan
hi perlIdentifier term=bold ctermfg=lightcyan
hi perlFunction term=bold ctermfg=Red
hi perlConditional term=bold ctermfg=Green
hi perlRepeat term=bold ctermfg=Green
hi! link perlFunctionName perlFunction
hi perlVarPlain term=bold ctermfg=Blue
hi perlVarPlain2 term=bold ctermfg=Cyan
hi perlString term=bold ctermfg=White
hi perlSpecial term=bold ctermfg=lightmagenta
endfunction
function CppDetected()
map ,e :call <SID>RunCppFile()<CR>
map ,g :call <SID>CompileCppFile()<CR>
map ,d :call <SID>DebugCppFile()<CR>
setlocal textwidth=80
set tags+=~/.vim/sys_basic_tags
endfunction
function PhpDetected()
map ,e :call <SID>RunPhpFile()<CR>
setlocal textwidth=80
endfunction
function s:CompileCFile()
if (stridx(bufname("%"), ".c")==-1)
echo "Not a c file"
return
endif
:update
let fileNameExt=bufname("%")
let fileName=substitute(fileNameExt, "\\(\\w\\+\\)\\.\\+.\\+", "\\1", "")
let cmd="gcc -Wall -o ./debug/".fileName.".exe ".fileNameExt
if isdirectory('debug')
let ret=system(cmd)
else
let ret=system("mkdir debug")
let ret=system(cmd)
endif
echo cmd."\n".ret
" echo fileNameExt."\n".fileName."\n".cmd."\n".re
endfunction
function s:CompileCForDebug()
if (stridx(bufname("%"), ".c")==-1)
echo "Not a c file"
return
endif
:update
let fileNameExt=bufname("%")
let fileName=substitute(fileNameExt, "\\(\\w\\+\\)\\.\\+.\\+", "\\1", "")
let cmd="gcc -Wall -Wextra -g -o ./debug/".fileName.".exe ".fileNameExt
if isdirectory('debug')
let ret=system(cmd)
else
let ret=system("mkdir debug")
let ret=system(cmd)
endif
echo cmd."\n".ret
endfunction
function s:RunCFile()
let FileName=bufname("%")
let FileName=substitute(FileName, "\\(\\w\\+\\)\\.\\+.\\+", "\\1", "")
if isdirectory('debug')
let path=getcwd()
let cmd=path."/debug/".FileName.".exe"
if filereadable(cmd)
exe "!".cmd
else
echo "No such file to execute."
endif
else
echo "No such directory to enter."
endif
endfunction
function s:DebugCFile()
let FileName=bufname("%")
let FileName=substitute(FileName, "\\(\\w\\+\\)\\.\\+.\\+", "\\1", "")
if isdirectory('debug')
let path=getcwd()
let cmd=path."/debug/".FileName.".exe"
if filereadable(cmd)
exe "!gdb ".cmd
else
echo "No such file to debug."
endif
else
echo "No such directory to enter."
endif
endfunction
function s:RunPerlFile()
:update
let FileName=bufname("%")
exe "! ".FileName
endfunction
function s:DebugPerlFile()
:update
let FileName=bufname("%")
exe "!perl -d ".FileName
endfunction
function s:CompileCppFile()
if (stridx(bufname("%"), ".cpp")==-1)
echo "Not a cpp file"
return
endif
:update
let fileNameExt=bufname("%")
let fileName=substitute(fileNameExt, "\\(\\w\\+\\)\\.\\+.\\+", "\\1", "")
let cmd="g++ -Wall -Wextra -g -o ./debug/".fileName.".exe ".fileNameExt
if isdirectory('debug')
let ret=system(cmd)
else
let ret=system("mkdir debug")
let ret=system(cmd)
endif
echo cmd."\n".ret
endfunction
function s:RunCppFile()
let FileName=bufname("%")
let FileName=substitute(FileName, "\\(\\w\\+\\)\\.\\+.\\+", "\\1", "")
if isdirectory('debug')
let path=getcwd()
let cmd=path."/debug/".FileName.".exe"
if filereadable(cmd)
exe "!".cmd
else
echo "No such file to execute."
endif
else
echo "No such directory to enter."
endif
endfunction
function s:DebugCppFile()
let FileName=bufname("%")
let FileName=substitute(FileName, "\\(\\w\\+\\)\\.\\+.\\+", "\\1", "")
if isdirectory('debug')
let path=getcwd()
let cmd=path."/debug/".FileName.".exe"
if filereadable(cmd)
exe "!gdb ".cmd
else
echo "No such file to debug."
endif
else
echo "No such directory to enter."
endif
endfunction
function s:RunPhpFile()
let FileName=bufname("%")
let cmd="php -e ".FileName." | more"
exe "!".cmd
endfunction
"+----------------------------------------------------------+
"| My Own Functions |
"| -END- |
"+----------------------------------------------------------+
" << FROM PANGU - END - >>