.vimrc - 哆啦比猫's Blog - I'm an ArchLinuxer

  1 set nocp
  2 syntax enable
  3 filetype plugin on
  4 set background=light
  5 set shell=sh
  6 
  7 " too slow when autocompleting!
  8 "set path+=/usr/include/**
  9 "set path+=/usr/local/include/**
 10 
 11 set number
 12 set autoindent
 13 set smartindent
 14 set tabstop=4
 15 set shiftwidth=4
 16 set noexpandtab
 17 
 18 set incsearch
 19 set mouse=a
 20 
 21 set textwidth=0
 22 set colorcolumn=76
 23 set scrolloff=4
 24 
 25 set nowrap
 26 set sidescrolloff=8
 27 set sidescroll=1
 28 
 29 set foldmethod=indent
 30 "set textwidth=70
 31 
 32 " fold all
 33 map <F2> zM
 34 " unfold all
 35 map <F3> zR
 36 map <F4> :call DebugWithoutMess()<CR>
 37 map <F5> :wa<CR>:make test<CR>
 38 map <C-F5> :call CompileAndRun()<CR>
 39 map <F6> :wa<CR>
 40 " toggle fold recursively
 41 map <F7> zA
 42 " toggle fold
 43 map <F8> za
 44 map <F9> :wa<CR>:!./configure<CR>
 45 map <F12> mtgg=G`t
 46 
 47 " remap vimwiki
 48 nmap <C-S-SPACE> VimwikiToggleListItem
 49 
 50 
 51 func! DebugWithoutMess()
 52     wa
 53     new
 54     make test
 55     q
 56 endf
 57 
 58 func! CompileAndRun()
 59     wa
 60     if &filetype == "c"
 61         exe "!gcc -Wall -std=gnu99 -O3 -march=native -lm -o %< % && ./%<"
 62     elseif &filetype == "cpp"
 63         exe "!g++ -Wall -std=gnu++0x -O3 -march=native -o %< % && ./%<"
 64     elseif &filetype == "dot"
 65         exe "!dot -T png -o %<.png % && feh %<.png"
 66     elseif &filetype == "lua"
 67         exe "!lua %"
 68     elseif &filetype == "sh"
 69         exe "!sh %"
 70     else
 71         echo "unknown filetype for compile-and-run"
 72     endif
 73 endf
 74 
 75 nmap XXXX ZQ
 76 nmap <C-f> <C-w>f
 77 nmap <C-d> gD
 78 
 79 imap <> <><LEFT>
 80 imap [] []<LEFT>
 81 imap "" ""<LEFT>
 82 imap '' ''<LEFT>
 83 imap {} {}<LEFT>
 84 imap () ()<LEFT>
 85 imap ,<SPACE> ,<SPACE>
 86 imap ,<CR> ,<CR>
 87 imap , ,<SPACE>
 88 
 89 
 90 " extra navigation in insert mode
 91 imap <c-l> <right>
 92 
 93 
 94 "set t_AF=^[[38;5;%dm
 95 "set t_AB=^[[48;5;%dm
 96 hi Folded ctermbg=black ctermfg=darkgray
 97 hi FoldedLineNr ctermbg=blue ctermfg=yellow
 98 
 99 
100 " extra highlighting and keybinding for C family language
101 func! ExtraC()
102     syn match cFunction "\zs\w\+\ze\s*("
103     hi def link cFunction Function
104 
105     syn match cppBinNumber "0b[01]\+"
106     hi def link cppBinNumber cNumber
107 
108     syn match cppUserType "\zs[a-z]\?[A-Z]\w*\ze\(\s\+\|\s*[*&]\+\s*\)[a-zA-Z0-9_:.]\+\s*[(){\[\],;=]"
109     syn match cppUserType "\zs[a-z]\w*_t\ze\(\s\+\|\s*[*&]\+\s*\)[a-zA-Z0-9_:.]\+\s*[(){\[\],;=]"
110     "syn match cUserType "\zs[a-zA-Z_][a-zA-Z_0-9]*\ze\(\s\+\|\s*[*&]\+\s*\)[a-zA-Z_][a-zA-Z_0-9]*\s*[(){\[\],;=]"
111     syn match cppUserType "->\s*\zs[a-z]\?[A-Z]\w*\ze"
112     hi def link cppUserType Type
113 
114     syn match cppTemplateType "\zs\w\+<[a-zA-Z0-9_>< *&,]\{-}\s*>\ze\(\s\+\|\s*[*&]\+\s*\)\w\+\s*[(){\[\],:;=]"
115     syn match cppTemplateType "\zs\w\+<[a-zA-Z0-9_>< *&,]\{-}\s*>\ze\s*[({]"
116     hi def link cppTemplateType Type
117 
118     syn match cppNamespacePrefix "\zs[a-zA-Z0-9_.:<>]\+\s*::\ze\w\+"
119     hi def link cppNamespacePrefix Special
120 
121     syn match cConstant "\<[a-z]\?[A-Z][A-Z0-9_]*\>"
122     syn clear cErrInParen
123 
124     syn keyword cStatement this create new create0 new0 auto
125     syn keyword cppType string stringstream iterator
126     syn keyword cType u8 u16 u32 u64 s8 s16 s32 s64 f32 f64
127 endf
128 au BufNewFile,BufRead *.[hc] call ExtraC()
129 au BufNewFile,BufRead *.hh call ExtraC()
130 au BufNewFile,BufRead *.cc call ExtraC()
131 au BufNewFile,BufRead *.hpp call ExtraC()
132 au BufNewFile,BufRead *.cpp call ExtraC()
133 
134 
135 " extra highlighting and keybinding for lua
136 func! ExtraLua()
137     syn match luaUserFunc "\.\s*\zs\w\+\ze\s*("
138     hi def link luaUserFunc luaSpecial
139 
140     syn match luaObjCall ":" contained
141     hi def link luaObjCall luaTable
142 
143     syn match luaUserMethod "\zs:\s*\w\+\ze\s*(" contains=luaObjCall
144     hi def link luaUserMethod luaSpecial
145 endf
146 au BufNewFile,BufRead *.lua call ExtraLua()
147 
148 
149 " highlighting for glsl
150 au BufNewFile,BufRead *.vp,*.fp setf glsl
151 
152 
153 " extra highlighting and keybinding for javascript 
154 func! ExtraJS()
155     syn match jsFunction "\zs\w\+\ze\s*("
156     hi def link jsFunction Keyword
157 endf
158 au BufNewFile,BufRead *.js call ExtraJS()
159 
160 
161 " fish filetype support
162 au BufNewFile,BufRead *.fish set filetype=fish
163 
164 
165 func! HighlightExtraSpace()
166     syn match ExtraSpace "\s\+$"
167     hi def link ExtraSpace Error
168 endfunc
169 au BufNewFile,BufRead * call HighlightExtraSpace()
170 
171 
172 " My own Tohtml
173 let g:html_ignore_folding = 1
174 func! Tohtml()
175     TOhtml
176     exe "norm gg"
177     exe "norm /pre {\<cr>"
178     exe "norm f{llifont-size: 12pt; padding: 0.5em; "
179     exe "norm f#lcwcccccc"      | " foreground color
180     exe "norm f#lcw000000"      | " background color
181     exe "norm jdd"              | " delete body {} style
182 
183     " save and close
184     wq
185     redraw
186     echom "Converted to " . expand("%") . ".html"
187 endf
188 com! Tohtml
189     \ let g:html_number_lines = 1
190     \ | call Tohtml()
191     \ | unlet g:html_number_lines
192 com! Tohtmlnonr
193     \ let g:html_number_lines = 0
194     \ | call Tohtml()
195     \ | unlet g:html_number_lines
196 
© 2010, 2011, 2012, 2013, 2014, 2015-2016 and 2017 Giumo Xavier Clanjor (哆啦比猫/兰威举).
© 2013, 2014, 2015-2016 and 2017 The Dark Colorscheme Designed by Giumo Xavier Clanjor (哆啦比猫/兰威举).
知识共享署名·非商业性使用·相同方式共享 3.0 中国大陆许可协议
| © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee