-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
253 lines (211 loc) · 7.91 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
" First, clear any existing autocommands:
autocmd!
" ******************
" * User Interface
" ******************
" General colorscheme
syntax on
set background=light
colorscheme desert
" Display line and column
set ruler
" Backspace
set backspace=indent,eol,start
set t_kb=
" Have command-line completion <Tab> (for filenames, help topics, option names)
set wildmode=list:longest,full
" Keep some context
set scrolloff=2
" Display the current mode and partially-typed commands in the status line:
set showmode
set showcmd
set loadplugins
" ******************
" * Auto build
" ******************
autocmd BufWritePost * silent execute "!touch ~/.vimsaved"
" ****************************
" * Commands and behaving
" ****************************
" Treat lines starting with a quote mark as comments
set comments+=b:\"
command -nargs=* CVSannotate silent call CVSannotate("<args>")
function! CVSannotate(cvsversion)
let filename=bufname("%")
new
execute "r!cvs annotate " . a:cvsversion . " " . filename
1d
set nomodified
endfunction
command CVSlog silent call CVSlog()
function! CVSlog()
let filename=bufname("%")
new
execute "r!cvs log -N " filename
1d
set nomodified
endfunction
command -nargs=* CVSdiff silent call CVSdiff("<args>")
function! CVSdiff(cvsversion)
diffthis
let filename=bufname("%")
vnew
execute "r!cvs -q up -p " . a:cvsversion . " " . filename
1d
diffthis
set nomodified
au BufDelete <buffer> wincmd p | diffoff | wincmd p
endfunction
"Create function SVNdiff with svn cat -r <N> <file>
command -nargs=* SVNdiff silent call SVNdiff("<args>")
function! SVNdiff(...)
let filename = bufname("%")
execute "vertical diffsplit new"
let svn_cmd="%!svn cat "
for s in a:000
let svn_cmd=svn_cmd . " " . s
endfor
let svn_cmd=svn_cmd . " " . filename
echom "Will execute: " . svn_cmd
execute svn_cmd
execute "diffupdate"
endfunction
"Create function SVNlog with svn log <file>
command -nargs=0 SVNlog silent call SVNlog()
function! SVNlog(...)
let filename = bufname("%")
execute "split log"
execute "%!svn log " . filename
endfunction
command -nargs=* HGannotate silent call HGannotate("<args>")
function! HGannotate(hgversion)
let filename=bufname("%")
new
execute "r!hg annotate -r " . a:hgversion . " " . filename
1d
set nomodified
endfunction
"Create function GitDiff with svn cat -r <N> <file>
command -nargs=* GitDiff silent call GitDiff("<args>")
function! GitDiff(...)
let filename = bufname("%")
execute "vertical diffsplit new"
let git_cmd="%!git show HEAD:./" . filename
echom "mWill execute: " . git_cmd
execute git_cmd
execute "diffupdate"
endfunction
command HGlog silent call HGlog()
function! HGlog()
let filename=bufname("%")
new
execute "r!hg log " filename
1d
set nomodified
endfunction
command -nargs=* HGdiff silent call HGdiff("<args>")
function! HGdiff(cvsversion)
diffthis
let filename=bufname("%")
vnew
execute "r!hg cat " . a:cvsversion . " " . filename
1d
diffthis
set nomodified
au BufDelete <buffer> wincmd p | diffoff | wincmd p
endfunction
" ****************************
" * Text Formatting -- General
" ****************************
" Try to indent automagically
set autoindent
" Limit text width to 80 characters
"set textwidth=80
" Alias for ConqueTerm
command ShellVSplit ConqueTermVSplit bash
command ShellSplit ConqueTermSplit bash
command Shell ConqueTerm bash
" Show lines longer than 80 characters
command HideLinesTooLong hi clear LineTooLong
command ShowLinesTooLong hi LineTooLong term=bold cterm=bold gui=bold guibg=LightYellow
ShowLinesTooLong
autocmd BufWinEnter,Syntax * exe "match LineTooLong /\\%>80v.\\+/"
HideLinesTooLong
" Change tab into 4 spaces, and set indent to 4 spaces
set shiftwidth=2
set tabstop=2
set expandtab
" Enable filetype detection:
filetype on
" For Perl programming, have things in braces indenting themselves:
autocmd FileType perl set smartindent
" In makefiles, don't expand tabs to spaces, since actual tab characters are
" needed, and have indentation at 8 chars to be sure that all indents are tabs
" (despite the mappings later):
autocmd FileType make setlocal noexpandtab shiftwidth=8
autocmd! BufNewFile,BufRead *.pde setlocal ft=arduino
autocmd! BufNewFile,BufRead *.ino setlocal ft=arduino
autocmd FileType python setlocal expandtab tabstop=4 shiftwidth=4
let python_highlight_indent_errors=1
let python_highlight_all=1
" Doesn't work, I don't know why
"autocmd FileType python hi SpacesInIndent ctermbg=yellow guibg=LightYellow
"autocmd FileType python exe "match SpacesInIndent /^\s* /"
command -nargs=0 CreatePyFile silent call CreatePyFile()
function! CreatePyFile()
execute "i"
#!/usr/bin/python
# -*- coding: utf8 -*-"
endfunction
autocmd! BufNewFile *.py CreatePyFile
" Octave syntax
augroup filetypedetect
au! BufRead,BufNewFile *.m,*.oct set filetype=octave
augroup END
" Use keywords from Octave syntax language file for autocomplete
if has("autocmd") && exists("+omnifunc")
autocmd Filetype octave
\ if &omnifunc == "" |
\ setlocal omnifunc=syntaxcomplete#Complete |
\ endif
endif
" Handle SConstruct and SConscript as python files
autocmd BufNewFile,BufRead SConstruct setf python
autocmd BufNewFile,BufRead SConscript setf python
autocmd BufNewFile,BufRead *.log_otf* setf logobe
autocmd BufNewFile,BufRead *.tags setf tags
" ******************
" * Search & Replace
" ******************
" Make searches case-insensitive, unless they contain upper-case letters:
"set ignorecase
"set smartcase
" Show the `best match so far' as search strings are typed:
set incsearch
set hlsearch
set modeline
com SearchError exe "/\\.[ch]p*:\\d*: error\\|scons:.*[eE]rror\\|No such file or directory\\|Error executing gramgen\\|there is [0-9]* error"
set shell=/bin/bash
"set makeprg=bms\ build\ -b
"set errorformat=%*[^\"]\"%f\"%*\\D%l:\ %m,\"%f\"%*\\D%l:\ %m,%-G%f:%l:\ (Each\ undeclared\ identifier\ is\ reported\ only\ once,%-G%f:%l:\ for\ each\ function\ it\ appears\ in.),%-GIn\ file\ included\ from\ %f:%l:%c:,%-GIn\ file\ included\ from\ %f:%l:%c\\,,%-GIn\ file\ included\ from\ %f:%l:%c,%-GIn\ file\ included\ from\ %f:%l,%-G%*[\ ]from\ %f:%l:%c,%-G%*[\ ]from\ %f:%l:,%-G%*[\ ]from\ %f:%l\\,,%-G%*[\ ]from\ %f:%l,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,\"%f\"\\,\ line\ %l%*\\D%c%*[^\ ]\ %m,%D%*\\a[%*\\d]:\ Entering\ directory\ `%f',%X%*\\a[%*\\d]:\ Leaving\ directory\ `%f',%D%*\\a:\ Entering\ directory\ `%f',%X%*\\a:\ Leaving\ directory\ `%f',%DMaking\ %*\\a\ in\ %f,%f\|%l\|\ %m
set errorformat=%*[^\"]\"%f\"%*\\D%l:\ %m,\"%f\"%*\\D%l:\ %m,%-G%f:%l:\ (Each\ undeclared\ identifier\ is\ reported\ only\ once,%-G%f:%l:\ for\ each\ function\ it\ appears\ in.),%-GIn\ file\ included\ from\ %f:%l:%c:,%-GIn\ file\ included\ from\ %f:%l:%c\\,,%-GIn\ file\ included\ from\ %f:%l:%c,%-GIn\ file\ included\ from\ %f:%l,%-G%*[\ ]from\ %f:%l:%c,%-G%*[\ ]from\ %f:%l:,%-G%*[\ ]from\ %f:%l\\,,%-G%*[\ ]from\ %f:%l,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,\"%f\"\\,\ line\ %l%*\\D%c%*[^\ ]\ %m,%Dmake:\ Entering\ directory\ `%f',%Xmake:\ Leaving\ directory\ `%f',%D%*\\a:\ Entering\ directory\ `%f',%X%*\\a:\ Leaving\ directory\ `%f',%DMaking\ %*\\a\ in\ %f,%f\|%l\|\ %m
if hostname() == "ncegcolnx138"
set makeprg=~intscs/delivery/bms/beta/bms\ build\ -t
endif
"set nocp
filetype plugin on
map <F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
" match pairs of < and >
autocmd FileType cpp set mps+=<:>
" YouCompleteMe configuration
"let g:ycm_global_ycm_extra_conf = "~/.vim/ycm_extra_conf.py"
let g:ycm_error_symbol = '->'
let g:ycm_warning_symbol = '>'
" Set Ctrl-u to uppercase the current word (usefull for macros)
inoremap <c-u> <esc>mpllbmbhelme`bgU`e`pa
set number relativenumber
" Spell check
set spelllang=en
autocmd FileType markdown setlocal spell
autocmd FileType gitcommit setlocal spell
autocmd FileType text setlocal spell