Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 316 lines (247 sloc) 8.605 kB
63af46f @scrooloose add the useful parts of my vimrc
authored
1 "Use Vim settings, rather then Vi settings (much better!).
2 "This must be first, because it changes other options as a side effect.
3 set nocompatible
4
2f51cb2 @scrooloose rearrange my vimrc and move some stuff in from my actual ~/.vimrc
authored
5 "activate pathogen
6 call pathogen#runtime_append_all_bundles()
7 call pathogen#helptags()
8
63af46f @scrooloose add the useful parts of my vimrc
authored
9 "allow backspacing over everything in insert mode
10 set backspace=indent,eol,start
11
12 "store lots of :cmdline history
13 set history=1000
14
15 set showcmd "show incomplete cmds down the bottom
16 set showmode "show current mode down the bottom
17
2f51cb2 @scrooloose rearrange my vimrc and move some stuff in from my actual ~/.vimrc
authored
18 set number "show line numbers
19
20 "display tabs and trailing spaces
21 set list
22 set listchars=tab:▷⋅,trail:⋅,nbsp:⋅
23
24
63af46f @scrooloose add the useful parts of my vimrc
authored
25 set incsearch "find the next match as we type the search
26 set hlsearch "hilight searches by default
27
2f51cb2 @scrooloose rearrange my vimrc and move some stuff in from my actual ~/.vimrc
authored
28 set wrap "dont wrap lines
63af46f @scrooloose add the useful parts of my vimrc
authored
29 set linebreak "wrap lines at convenient points
30
2f51cb2 @scrooloose rearrange my vimrc and move some stuff in from my actual ~/.vimrc
authored
31 if v:version >= 703
32 "undo settings
33 set undodir=~/.vim/undofiles
34 set undofile
35
36 set colorcolumn=+1 "mark the ideal max text width
37 endif
38
39 "default indent settings
40 set shiftwidth=4
41 set softtabstop=4
42 set expandtab
43 set autoindent
44
45 "folding settings
46 set foldmethod=indent "fold based on indent
47 set foldnestmax=3 "deepest fold is 3 levels
48 set nofoldenable "dont fold by default
49
50 set wildmode=list:longest "make cmdline tab completion similar to bash
51 set wildmenu "enable ctrl-n and ctrl-p to scroll thru matches
52 set wildignore=*.o,*.obj,*~ "stuff to ignore when tab completing
53
54 set formatoptions-=o "dont continue comments when pushing o/O
55
56 "vertical/horizontal scroll off settings
57 set scrolloff=3
58 set sidescrolloff=7
59 set sidescroll=1
60
61 "load ftplugins and indent files
62 filetype plugin on
63 filetype indent on
64
65 "turn on syntax highlighting
66 syntax on
67
68 "some stuff to get the mouse going in term
69 set mouse=a
70 set ttymouse=xterm2
71
72 "tell the term has 256 colors
73 set t_Co=256
74
75 "hide buffers when not displayed
76 set hidden
77
63af46f @scrooloose add the useful parts of my vimrc
authored
78 "statusline setup
65b60db @scrooloose display full path on statusline
authored
79 set statusline=%f "tail of the filename
9e25fad @scrooloose only show &ff and &fenc if they arent unix/utf-8
authored
80
81 "display a warning if fileformat isnt unix
82 set statusline+=%#warningmsg#
83 set statusline+=%{&ff!='unix'?'['.&ff.']':''}
84 set statusline+=%*
85
86 "display a warning if file encoding isnt utf-8
87 set statusline+=%#warningmsg#
410f2f9 @scrooloose dont show empty brackets when theres no &fenc
authored
88 set statusline+=%{(&fenc!='utf-8'&&&fenc!='')?'['.&fenc.']':''}
9e25fad @scrooloose only show &ff and &fenc if they arent unix/utf-8
authored
89 set statusline+=%*
90
63af46f @scrooloose add the useful parts of my vimrc
authored
91 set statusline+=%h "help file flag
92 set statusline+=%y "filetype
26a6792 @scrooloose make the statusline own harder
authored
93 set statusline+=%r "read only flag
94 set statusline+=%m "modified flag
03cf502 @scrooloose make the statusline own harder
authored
95
9f5a0fd @scrooloose maket the tab warning on the stl own more
authored
96 "display a warning if &et is wrong, or we have mixed-indenting
03cf502 @scrooloose make the statusline own harder
authored
97 set statusline+=%#error#
98 set statusline+=%{StatuslineTabWarning()}
99 set statusline+=%*
100
26a6792 @scrooloose make the statusline own harder
authored
101 set statusline+=%{StatuslineTrailingSpaceWarning()}
07d5ca1 @scrooloose error highlight display the [paste] flag
authored
102
0596fef @scrooloose add a statusline warning if long lines are detected
authored
103 set statusline+=%{StatuslineLongLineWarning()}
104
a747a2b @scrooloose completely refactor the syntax checking
authored
105 set statusline+=%#warningmsg#
facb166 @scrooloose use the syntastic syntax checking plugin
authored
106 set statusline+=%{SyntasticStatuslineFlag()}
a747a2b @scrooloose completely refactor the syntax checking
authored
107 set statusline+=%*
108
07d5ca1 @scrooloose error highlight display the [paste] flag
authored
109 "display a warning if &paste is set
110 set statusline+=%#error#
111 set statusline+=%{&paste?'[paste]':''}
112 set statusline+=%*
113
63af46f @scrooloose add the useful parts of my vimrc
authored
114 set statusline+=%= "left/right separator
26a6792 @scrooloose make the statusline own harder
authored
115 set statusline+=%{StatuslineCurrentHighlight()}\ \ "current highlight
63af46f @scrooloose add the useful parts of my vimrc
authored
116 set statusline+=%c, "cursor column
117 set statusline+=%l/%L "cursor line/total lines
118 set statusline+=\ %P "percent through file
119 set laststatus=2
120
26a6792 @scrooloose make the statusline own harder
authored
121 "recalculate the trailing whitespace warning when idle, and after saving
122 autocmd cursorhold,bufwritepost * unlet! b:statusline_trailing_space_warning
123
124 "return '[\s]' if trailing white space is detected
125 "return '' otherwise
126 function! StatuslineTrailingSpaceWarning()
127 if !exists("b:statusline_trailing_space_warning")
b4ad446 @scrooloose supress statusbar warnings if the file is not modifiable
authored
128
129 if !&modifiable
130 let b:statusline_trailing_space_warning = ''
131 return b:statusline_trailing_space_warning
132 endif
133
26a6792 @scrooloose make the statusline own harder
authored
134 if search('\s\+$', 'nw') != 0
135 let b:statusline_trailing_space_warning = '[\s]'
136 else
137 let b:statusline_trailing_space_warning = ''
138 endif
139 endif
140 return b:statusline_trailing_space_warning
141 endfunction
142
143
144 "return the syntax highlight group under the cursor ''
ce89cd0 @scrooloose add hilight group under cursor to statusline
authored
145 function! StatuslineCurrentHighlight()
146 let name = synIDattr(synID(line('.'),col('.'),1),'name')
26a6792 @scrooloose make the statusline own harder
authored
147 if name == ''
148 return ''
149 else
150 return '[' . name . ']'
ce89cd0 @scrooloose add hilight group under cursor to statusline
authored
151 endif
152 endfunction
153
9f5a0fd @scrooloose maket the tab warning on the stl own more
authored
154 "recalculate the tab warning flag when idle and after writing
155 autocmd cursorhold,bufwritepost * unlet! b:statusline_tab_warning
156
157 "return '[&et]' if &et is set wrong
158 "return '[mixed-indenting]' if spaces and tabs are used to indent
159 "return an empty string if everything is fine
03cf502 @scrooloose make the statusline own harder
authored
160 function! StatuslineTabWarning()
9f5a0fd @scrooloose maket the tab warning on the stl own more
authored
161 if !exists("b:statusline_tab_warning")
b4ad446 @scrooloose supress statusbar warnings if the file is not modifiable
authored
162 let b:statusline_tab_warning = ''
163
164 if !&modifiable
165 return b:statusline_tab_warning
166 endif
167
d2bd003 @scrooloose update statusline hax
authored
168 let tabs = search('^\t', 'nw') != 0
9f5a0fd @scrooloose maket the tab warning on the stl own more
authored
169
01e5c6e @scrooloose another fix to the intent stl flag
authored
170 "find spaces that arent used as alignment in the first indent column
171 let spaces = search('^ \{' . &ts . ',}[^\t]', 'nw') != 0
3ae194e @scrooloose upgrade the statsline indent warning
authored
172
9f5a0fd @scrooloose maket the tab warning on the stl own more
authored
173 if tabs && spaces
01e5c6e @scrooloose another fix to the intent stl flag
authored
174 let b:statusline_tab_warning = '[mixed-indenting]'
9f5a0fd @scrooloose maket the tab warning on the stl own more
authored
175 elseif (spaces && !&et) || (tabs && &et)
176 let b:statusline_tab_warning = '[&et]'
177 endif
03cf502 @scrooloose make the statusline own harder
authored
178 endif
9f5a0fd @scrooloose maket the tab warning on the stl own more
authored
179 return b:statusline_tab_warning
03cf502 @scrooloose make the statusline own harder
authored
180 endfunction
181
0596fef @scrooloose add a statusline warning if long lines are detected
authored
182 "recalculate the long line warning when idle and after saving
183 autocmd cursorhold,bufwritepost * unlet! b:statusline_long_line_warning
184
dcfd921 @scrooloose bugfix and awesomify the long line warning
authored
185 "return a warning for "long lines" where "long" is either &textwidth or 80 (if
186 "no &textwidth is set)
187 "
188 "return '' if no long lines
d47587e @scrooloose decompose the statusline long line warning function
authored
189 "return '[#x,my,$z] if long lines are found, were x is the number of long
190 "lines, y is the median length of the long lines and z is the length of the
191 "longest line
0596fef @scrooloose add a statusline warning if long lines are detected
authored
192 function! StatuslineLongLineWarning()
193 if !exists("b:statusline_long_line_warning")
b4ad446 @scrooloose supress statusbar warnings if the file is not modifiable
authored
194
195 if !&modifiable
196 let b:statusline_long_line_warning = ''
197 return b:statusline_long_line_warning
198 endif
199
d47587e @scrooloose decompose the statusline long line warning function
authored
200 let long_line_lens = s:LongLines()
0596fef @scrooloose add a statusline warning if long lines are detected
authored
201
e2ef6c8 @scrooloose make the long line warning more awesome
authored
202 if len(long_line_lens) > 0
d47587e @scrooloose decompose the statusline long line warning function
authored
203 let b:statusline_long_line_warning = "[" .
204 \ '#' . len(long_line_lens) . "," .
205 \ 'm' . s:Median(long_line_lens) . "," .
206 \ '$' . max(long_line_lens) . "]"
0596fef @scrooloose add a statusline warning if long lines are detected
authored
207 else
208 let b:statusline_long_line_warning = ""
209 endif
210 endif
211 return b:statusline_long_line_warning
212 endfunction
213
d47587e @scrooloose decompose the statusline long line warning function
authored
214 "return a list containing the lengths of the long lines in this buffer
215 function! s:LongLines()
216 let threshold = (&tw ? &tw : 80)
217 let spaces = repeat(" ", &ts)
218
219 let long_line_lens = []
220
221 let i = 1
222 while i <= line("$")
223 let len = strlen(substitute(getline(i), '\t', spaces, 'g'))
224 if len > threshold
225 call add(long_line_lens, len)
226 endif
227 let i += 1
228 endwhile
229
230 return long_line_lens
231 endfunction
232
e2ef6c8 @scrooloose make the long line warning more awesome
authored
233 "find the median of the given array of numbers
234 function! s:Median(nums)
235 let nums = sort(a:nums)
236 let l = len(nums)
237
238 if l % 2 == 1
239 let i = (l-1) / 2
240 return nums[i]
241 else
242 return (nums[l/2] + nums[(l/2)-1]) / 2
243 endif
244 endfunction
245
2f51cb2 @scrooloose rearrange my vimrc and move some stuff in from my actual ~/.vimrc
authored
246 "syntastic settings
247 let g:syntastic_enable_signs=1
248 let g:syntastic_auto_loc_list=1
249
250 "snipmate settings
251 let g:snips_author = "Martin Grenfell"
252
253 "taglist settings
254 let Tlist_Compact_Format = 1
255 let Tlist_Enable_Fold_Column = 0
256 let Tlist_Exit_OnlyWindow = 0
257 let Tlist_WinWidth = 35
258 let tlist_php_settings = 'php;c:class;f:Functions'
259 let Tlist_Use_Right_Window=1
260 let Tlist_GainFocus_On_ToggleOpen = 1
261 let Tlist_Display_Tag_Scope = 1
262 let Tlist_Process_File_Always = 1
263
264 "nerdtree settings
265 let g:NERDTreeMouseMode = 2
266 let g:NERDTreeWinSize = 40
267
268 "explorer mappings
269 nnoremap <f1> :BufExplorer<cr>
270 nnoremap <f2> :NERDTreeToggle<cr>
271 nnoremap <f3> :TlistToggle<cr>
272
273 "source project specific config files
274 runtime! projects/**/*.vim
63af46f @scrooloose add the useful parts of my vimrc
authored
275
332c677 @scrooloose dont source csapprox if we dont have gui support
authored
276 "dont load csapprox if we no gui support - silences an annoying warning
277 if !has("gui")
278 let g:CSApprox_loaded = 1
279 endif
280
63af46f @scrooloose add the useful parts of my vimrc
authored
281 "make <c-l> clear the highlight as well as redraw
282 nnoremap <C-L> :nohls<CR><C-L>
283 inoremap <C-L> <C-O>:nohls<CR>
284
285 "map Q to something useful
286 noremap Q gq
287
288 "make Y consistent with C and D
289 nnoremap Y y$
290
291 "visual search mappings
292 function! s:VSetSearch()
293 let temp = @@
294 norm! gvy
295 let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g')
296 let @@ = temp
297 endfunction
298 vnoremap * :<C-u>call <SID>VSetSearch()<CR>//<CR>
299 vnoremap # :<C-u>call <SID>VSetSearch()<CR>??<CR>
300
301
f170376 @scrooloose add some more to the vimrc
authored
302 "jump to last cursor position when opening a file
303 "dont do it when writing a commit log entry
63af46f @scrooloose add the useful parts of my vimrc
authored
304 autocmd BufReadPost * call SetCursorPosition()
305 function! SetCursorPosition()
08b6a53 @scrooloose dont change the cursor position for svn files
authored
306 if &filetype !~ 'svn\|commit\c'
63af46f @scrooloose add the useful parts of my vimrc
authored
307 if line("'\"") > 0 && line("'\"") <= line("$")
f5bd12f @scrooloose use normal! and center screen when restoring cursor position
authored
308 exe "normal! g`\""
309 normal! zz
63af46f @scrooloose add the useful parts of my vimrc
authored
310 endif
311 end
312 endfunction
313
b7420f5 @scrooloose enable spell check when writing commit logs
authored
314 "spell check when writing commit logs
315 autocmd filetype svn,*commit* set spell
Something went wrong with that request. Please try again.