1
2
3
4 if has('autocmd')
5
6 au!
7 endif
8
9 set nocompatible
10 filetype off
11
12 set viminfo=<100,'100,/50,:100,h,r$TEMP:,s10
13
14
15
16
17
18
19
20
21
22
23
24 source $VIMRUNTIME/vimrc_example.vim
25 source $VIMRUNTIME/mswin.vim
26 behave mswin
27
28 if has('win32') || has ('win64')
29 let $VIMFILES = '""' . $VIM . '\vimfiles"'
30 else
31 let $VIMFILES = $HOME."/.vim"
32 endif
33
34 set t_Co=256
35 set background=dark
36
37 set path+=./**
38 set backup
39 set backupdir=C:\Temp
40 set backupskip=C:\Temp
41 set noswapfile
42 set undofile
43 set undodir=C:\Temp
44 set undolevels=1000
45 set history=1000
46 set ignorecase
47 set infercase
48 set smartcase
49 set smarttab
50 set backspace=indent,eol,start
51 set confirm
52 set autoindent
53 set copyindent
54 set showmatch
55 set incsearch
56 set visualbell
57 set showcmd
58 set showmode
59 set wildmenu
60 set wildmode=list:longest,full
61 set wildignore=*.dll,*.exe,*.gif,*.jpg,*.mm
62 set esckeys
63 set modeline
64 set modelines=4
65 set report=0
66 set shortmess-=S
67 set dictionary=D:\cygwin64\usr\share\dict\linux.words
68 set thesaurus=$HOME\vimfiles\thesaurus\english.txt
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83 set shellxquote=\"
84
85
86
87
88
89
90
91
92
93 "]"
94 "["
95 "~"
96
97
98 "l"
99 "h"
100
101
102
103
104 set wrap
105 map <F2> <Esc>:set nowrap<CR>
106 map <S-F2> <Esc>:set wrap<CR>
107
108 noremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j')
109 noremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k')
110
111
112 fun! JoinSpaceless()
113 execute 'normal gJ'
114
115 if matchstr(getline('.'), '\%' . col('.') . 'c.') =~ '\s'
116
117 execute 'normal dw'
118 endif
119 endfun
120 nnoremap <F10> :call JoinSpaceless()<CR>
121
122
123
124
125
126
127 set pastetoggle=<F5>
128
129 set paste
130
131 set clipboard=unnamed
132
133
134
135
136 set cursorline cursorcolumn
137 highlight Cursor guifg=white guibg=#1874cd
138 highlight iCursor guifg=white guibg=#1874cd
139 highlight CursorLine guibg=white
140
141
142 set langmenu=en_US
143 let $LANG = 'en_US'
144 source $VIMRUNTIME/delmenu.vim
145 source $VIMRUNTIME/menu.vim
146
147 set number
148
149 hi CursorLineNr guifg=silver
150
151 set mouse=a
152 autocmd GUIEnter * simalt ~x
153 set ruler
154
155
156
157
158 amenu <silent>Tabs.New<TAB>Open\ a\ new\ tab :tabnew<CR>
159 amenu Tabs.-SEPT1- :
160 amenu <silent>Tabs.&Next :tabnext<CR>
161 amenu <silent>Tabs.&Previous :tabprevious<CR>
162 amenu Tabs.-SEPT2- :
163 amenu Tabs.&Close :confirm tabclose<CR>
164
165
166
167
168
169
170
171 amenu 1.10 ToolBar.New :new<CR>
172 amenu 1.20 ToolBar.Open :browse confirm e<CR>
173
174 an 1.400 ToolBar.-sep8- <Nop>
175 an icon=WinMax 1.410 ToolBar.Maximize <C-w>_
176 an icon=WinVSplit 1.420 ToolBar.ResizeEqual <C-w>=
177
178
179
180
181 tmenu 1.10 ToolBar.New New
182 tmenu 1.20 ToolBar.Open Open
183 tmenu 1.30 ToolBar.Save Save
184 tmenu 1.40 ToolBar.SaveAll Save All
185 tmenu 1.50 ToolBar.Print Print
186 tmenu 1.60 ToolBar.Undo Undo
187 tmenu 1.70 ToolBar.Redo Redo
188 tmenu 1.80 ToolBar.Cut Cut
189 tmenu 1.90 ToolBar.Copy Copy
190 tmenu 1.100 ToolBar.Paste Paste
191 tmenu 1.310 ToolBar.Maximize Maximize Buffer
192 tmenu 1.320 ToolBar.ResizeEqual Resize Equal Buffer
193
194
195
196 set fileencoding=utf-8
197 set encoding=utf-8
198 set tenc=utf-8
199 set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
200
201
202 language message en_US.UTF-8
203
204 set autoread
205
206
207 set printheader=%<%f%h%m%40{strftime(\"%I:%M:%S\ \%p,\ %a\ %b\ %d,\ %Y\")}%=Page\ %N
208
209
210 set printheader=%<%f%h%m\ %40{strftime(\"%c\",getftime(expand(\"%%\")))}%=Page\ %N
211
212
213 filetype plugin on
214
215 if has("autocmd") && exists("+omnifunc")
216 autocmd Filetype *
217 \ if &omnifunc == "" |
218 \ setlocal omnifunc=syntaxcomplete#Complete |
219 \ endif
220 endif
221
222
223 au FilterWritePre * if &diff | colorscheme default | endif
224
225
226 if &diff
227 colorscheme default
228 else
229 colorscheme Tomorrow-Night
230 endif
231
232
233
234 set laststatus=2
235 set statusline=%2*%n%m%r%h%w%*\ %F\ %1*[FORMAT=%2*%{&ff}:%{&fenc!=''?&fenc:&enc}%1*]\ [TYPE=%2*%Y%1*]\ [COL=%2*%03v%1*]\ [ROW=%2*%03l%1*/%3*%L(%p%%)%1*]
236
237 function! InsertStatuslineColor(mode)
238 if a:mode == 'i'
239 hi statusline guibg=peru
240 elseif a:mode == 'r'
241 hi statusline guibg=blue
242 else
243 hi statusline guibg=#1C1C1C
244 endif
245 endfunction
246
247 au InsertEnter * call InsertStatuslineColor(v:insertmode)
248 au InsertLeave * hi statusline guibg=#1C1C1C guifg=white
249
250 hi statusline guibg=#1C1C1C
251 hi User1 guifg=gray
252 hi User2 guifg=peru
253 hi User3 guifg=white
254 hi User4 gui=bold
255
256
257
258 if has('gui_running')
259
260
261 set guioptions-=m
262 set guioptions-=T
263 set guioptions-=r
264 set guioptions-=l
265 set guioptions-=b
266
267 nnoremap <C-F1> :if &go=~#'m'<Bar>set go-=m<Bar>else<Bar>set go+=m<Bar>endif<CR>
268 nnoremap <C-F2> :if &go=~#'T'<Bar>set go-=T<Bar>else<Bar>set go+=T<Bar>endif<CR>
269 nnoremap <C-F3> :if &go=~#'r'<Bar>set go-=r<Bar>else<Bar>set go+=r<Bar>endif<CR>
270
271 if has("win16") || has("win32") || has("win95") || has("win64")
272 set guifont=Sarasa\ Mono\ SC:h11,SpaceMono\ NF:h11,Inconsolata:h12,Consolas:h11,Courier_New:h11:cANSI
273
274 else
275 set guifont=MiscFixed\ Semi-Condensed\ 10
276 endif
277 endif
278
279
280
281
282
283 nnoremap <space> za
284
285
286
287
288
289 vnoremap < <gv
290 vnoremap > >gv
291
292 nnoremap <C-Insert> :tabnew<CR>
293 nnoremap <C-Delete> :tabclose<CR>
294
295 noremap <silent><tab>m :tabnew<cr>
296 noremap <silent><tab>e :tabclose<cr>
297 noremap <silent><tab>n :tabn<cr>
298 noremap <silent><tab>p :tabp<cr>
299 noremap <silent><s-tab> :tabnext<CR>
300 inoremap <silent><s-tab> <ESC>:tabnext<CR>
301
302
303 vmap <silent> // y/<C-R>=escape(@", '\\/.*$^~[]')<CR><CR>
304
305
306 noremap <silent> <F1> :execute "tab h " . expand("<cword>")<cr>
307
308
309 nmap <silent> <F6> <Esc>:call ToggleCursor()<CR>
310
311
312 nmap <silent> <F7> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
313
314
315 let notabs = 0
316 nnoremap <silent> <F8> :let notabs=!notabs<Bar>:if notabs<Bar>:tabo<Bar>:else<Bar>:tab ball<Bar>:tabn<Bar>:endif<CR>
317
318 function! ToggleCursor()
319 if &cursorcolumn
320 set nocursorline nocursorcolumn
321 else
322 set cursorline cursorcolumn
323 endif
324 endfunction
325
326
327 nmap <silent> ,/ :nohlsearch<CR>
328
329 function! ToggleHLSearch()
330 if &hls
331 set nohls
332 else
333 set hls
334 endif
335 endfunction
336
337
338 nnoremap / /\v
339 vnoremap / /\v
340 cnoremap %s/ %s/\v
341 nnoremap :g/ :g/\v
342
343 set grepprg=grep\ -rnIH\ --exclude-dir=.git
344
345 let mapleader=","
346
347 nmap <silent> <leader><space> <Esc>:call ToggleHLSearch()<CR>
348
349
350
351 inoremap <C-Enter> </<C-x><C-o>
352
353
354 nnoremap <leader>mt :match errorMsg /[^\t]\zs\t\+/<CR>
355
356
357 nmap <silent> <leader>tv :tabe $MYVIMRC<CR>
358 nmap <silent> <leader>sv :so $MYVIMRC<CR>
359 autocmd BufWritePost $MYVIMRC source $MYVIMRC
360
361
362 nnoremap <leader>p V`]
363
364
365 let g:browsefilter = "*.*"
366 nnoremap <leader>v :browse tabe E:\Anthony_GitHub\learn-vim<CR>
367
368
369 nnoremap <leader>w :browse sav<CR>
370
371
372 nnoremap <leader>cd :cd %:p:h<CR>:pwd<CR>
373
374 nnoremap <leader>cc :!start cmd /k cd %:p:h:8<cr>
375
376 nnoremap <leader>ce :!start explorer %:p:h:8<cr>
377
378
379 nmap <leader>fn :let @*=substitute(expand("%"), "/", "\\", "g")<CR>
380 nmap <leader>fp :let @*=substitute(expand("%:p"), "/", "\\", "g")<CR>
381
382 vnoremap <leader>a <c-a>
383 vnoremap <leader>x <c-x>
384
385
386
387
388 nnoremap <leader>ml :setlocal invmodeline <bar> doautocmd BufRead<cr>
389
390
391
392
393 autocmd BufWinLeave * call clearmatches()
394 set nospell
395
396
397
398
399 abbreviate #b /**********************
400 abbreviate #e **********************/
401 iabbrev pcode <p style="text-indent:2em"><code class="inset"></code></p><Esc>2F<i
402 iabbrev icode <code class="inset"></code><Esc>F<i
403
404
405
406
407
408
409
410 autocmd! BufNewFile * silent! 0r $VIM/vimfiles/skel/Template.%:e
411
412
413 set foldenable
414 set foldmethod=marker
415 set foldcolumn=2
416
417
418 set list
419 set listchars=tab:\|.,trail:,nbsp:.,extends:¬
420
421
422
423
424
425
426 au FocusLost * :wa
427
428
429
430 function! TwiddleCase(str)
431 if a:str ==# toupper(a:str)
432 let result = tolower(a:str)
433 elseif a:str ==# tolower(a:str)
434 let result = substitute(a:str,'\(\<\w\+\>\)', '\u\1', 'g')
435 else
436 let result = toupper(a:str)
437 endif
438 return result
439 endfunction
440 vnoremap ~ y:call setreg('', TwiddleCase(@"), getregtype(''))<CR>gv""Pgvl
441
442
443
444
445
446 function! HtmlEntities(line1, line2, action)
447 let search = @/
448 let range = 'silent ' . a:line1 . ',' . a:line2
449 if a:action == 0
450 execute range . 'sno/</</eg'
451 execute range . 'sno/>/>/eg'
452 execute range . 'sno/&/&/eg'
453 else
454 execute range . 'sno/&/&/eg'
455 execute range . 'sno/</</eg'
456 execute range . 'sno/>/>/eg'
457 endif
458 nohl
459 let @/ = search
460 endfunction
461
462 command! -range -nargs=1 HEntities call HtmlEntities(<line1>, <line2>, <args>)
463
464 noremap <silent> <Leader>hu :HEntities 0<CR>
465 noremap <silent> <Leader>he :HEntities 1<CR>
466
467 map <silent> <F9> <Esc>:HEntities 1<CR>
468
469
470
471
472
473 augroup filetypedetect
474 au BufNewFile,BufRead *.csc setfiletype csc
475 au BufNewFile,BufRead *.msh setfiletype mxl
476 au BufNewFile,BufRead *.mxl setfiletype mxl
477 au BufNewFile,BufRead *.rle setfiletype rle
478 au BufNewFile,BufRead *.log setfiletype log
479 augroup end
480
481
482
483
484 augroup vimrc-auto-mkdir
485 autocmd!
486 autocmd BufWritePre * call s:auto_mkdir(expand('<afile>:p:h'), v:cmdbang)
487 function! s:auto_mkdir(dir, force)
488 if !isdirectory(a:dir)
489 \ && (a:force
490 \ || input("'" . a:dir . "' does not exist. Create? [y/N]") =~? '^y\%[es]$')
491 call mkdir(iconv(a:dir, &encoding, &termencoding), 'p')
492 endif
493 endfunction
494 augroup END
495
496 augroup vgrep
497 autocmd!
498 autocmd QuickFixCmdPost [^l]* cwindow
499 autocmd QuickFixCmdPost l* lwindow
500 augroup END
501
502
503
504
505 command! -bar DelTab %s/ //
506 command! DelLF %s/\n//
507 command! FmtCode DelTab|DelLF
508
509
510
511 set pythonthreehome=C:\tools\Python3
512 set pythonthreedll=C:\tools\Python3\python38.dll
513 augroup make_python
514 au!
515 au FileType python set makeprg=C:\tools\Python3\python\ %
516 augroup end
517
518
519
520
521 unmap <C-F>
522
523
524 nnoremap x "_x
525
526
527
528 set colorcolumn=70
529 highlight ColorColumn guibg=darkred
530