Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 319 lines (249 sloc) 8.675 kb
63af46f3 »
2008-09-21 add the useful parts of my vimrc
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
2f51cb25 »
2011-02-08 rearrange my vimrc and move some stuff in from my actual ~/.vimrc
5 "activate pathogen
6 call pathogen#runtime_append_all_bundles()
7 call pathogen#helptags()
8
63af46f3 »
2008-09-21 add the useful parts of my vimrc
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
2f51cb25 »
2011-02-08 rearrange my vimrc and move some stuff in from my actual ~/.vimrc
18 set number "show line numbers
19
20 "display tabs and trailing spaces
21 set list
22 set listchars=tab:▷⋅,trail:⋅,nbsp:⋅
23
24
63af46f3 »
2008-09-21 add the useful parts of my vimrc
25 set incsearch "find the next match as we type the search
26 set hlsearch "hilight searches by default
27
2f51cb25 »
2011-02-08 rearrange my vimrc and move some stuff in from my actual ~/.vimrc
28 set wrap "dont wrap lines
63af46f3 »
2008-09-21 add the useful parts of my vimrc
29 set linebreak "wrap lines at convenient points
30
2f51cb25 »
2011-02-08 rearrange my vimrc and move some stuff in from my actual ~/.vimrc
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
63af46f3 »
2008-09-21 add the useful parts of my vimrc
78 "statusline setup
65b60db8 »
2008-11-30 display full path on statusline
79 set statusline=%f "tail of the filename
9e25fad6 »
2009-02-01 only show &ff and &fenc if they arent unix/utf-8
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#
410f2f92 »
2009-02-02 dont show empty brackets when theres no &fenc
88 set statusline+=%{(&fenc!='utf-8'&&&fenc!='')?'['.&fenc.']':''}
9e25fad6 »
2009-02-01 only show &ff and &fenc if they arent unix/utf-8
89 set statusline+=%*
90
63af46f3 »
2008-09-21 add the useful parts of my vimrc
91 set statusline+=%h "help file flag
92 set statusline+=%y "filetype
26a67929 »
2008-10-29 make the statusline own harder
93 set statusline+=%r "read only flag
94 set statusline+=%m "modified flag
03cf502e »
2008-10-28 make the statusline own harder
95
036e2d6d »
2011-05-18 add a bunch of plugins as submodules
96 set statusline+=%{fugitive#statusline()}
97
9f5a0fdc »
2008-10-29 maket the tab warning on the stl own more
98 "display a warning if &et is wrong, or we have mixed-indenting
03cf502e »
2008-10-28 make the statusline own harder
99 set statusline+=%#error#
100 set statusline+=%{StatuslineTabWarning()}
101 set statusline+=%*
102
26a67929 »
2008-10-29 make the statusline own harder
103 set statusline+=%{StatuslineTrailingSpaceWarning()}
07d5ca1e »
2008-11-19 error highlight display the [paste] flag
104
0596fefb »
2009-06-18 add a statusline warning if long lines are detected
105 set statusline+=%{StatuslineLongLineWarning()}
106
a747a2b8 »
2009-06-28 completely refactor the syntax checking
107 set statusline+=%#warningmsg#
facb166b »
2009-07-12 use the syntastic syntax checking plugin
108 set statusline+=%{SyntasticStatuslineFlag()}
a747a2b8 »
2009-06-28 completely refactor the syntax checking
109 set statusline+=%*
110
07d5ca1e »
2008-11-19 error highlight display the [paste] flag
111 "display a warning if &paste is set
112 set statusline+=%#error#
113 set statusline+=%{&paste?'[paste]':''}
114 set statusline+=%*
115
63af46f3 »
2008-09-21 add the useful parts of my vimrc
116 set statusline+=%= "left/right separator
26a67929 »
2008-10-29 make the statusline own harder
117 set statusline+=%{StatuslineCurrentHighlight()}\ \ "current highlight
63af46f3 »
2008-09-21 add the useful parts of my vimrc
118 set statusline+=%c, "cursor column
119 set statusline+=%l/%L "cursor line/total lines
120 set statusline+=\ %P "percent through file
121 set laststatus=2
122
26a67929 »
2008-10-29 make the statusline own harder
123 "recalculate the trailing whitespace warning when idle, and after saving
124 autocmd cursorhold,bufwritepost * unlet! b:statusline_trailing_space_warning
125
126 "return '[\s]' if trailing white space is detected
127 "return '' otherwise
128 function! StatuslineTrailingSpaceWarning()
129 if !exists("b:statusline_trailing_space_warning")
b4ad446a »
2010-07-01 supress statusbar warnings if the file is not modifiable
130
131 if !&modifiable
132 let b:statusline_trailing_space_warning = ''
133 return b:statusline_trailing_space_warning
134 endif
135
26a67929 »
2008-10-29 make the statusline own harder
136 if search('\s\+$', 'nw') != 0
137 let b:statusline_trailing_space_warning = '[\s]'
138 else
139 let b:statusline_trailing_space_warning = ''
140 endif
141 endif
142 return b:statusline_trailing_space_warning
143 endfunction
144
145
146 "return the syntax highlight group under the cursor ''
ce89cd03 »
2008-10-08 add hilight group under cursor to statusline
147 function! StatuslineCurrentHighlight()
148 let name = synIDattr(synID(line('.'),col('.'),1),'name')
26a67929 »
2008-10-29 make the statusline own harder
149 if name == ''
150 return ''
151 else
152 return '[' . name . ']'
ce89cd03 »
2008-10-08 add hilight group under cursor to statusline
153 endif
154 endfunction
155
9f5a0fdc »
2008-10-29 maket the tab warning on the stl own more
156 "recalculate the tab warning flag when idle and after writing
157 autocmd cursorhold,bufwritepost * unlet! b:statusline_tab_warning
158
159 "return '[&et]' if &et is set wrong
160 "return '[mixed-indenting]' if spaces and tabs are used to indent
161 "return an empty string if everything is fine
03cf502e »
2008-10-28 make the statusline own harder
162 function! StatuslineTabWarning()
9f5a0fdc »
2008-10-29 maket the tab warning on the stl own more
163 if !exists("b:statusline_tab_warning")
b4ad446a »
2010-07-01 supress statusbar warnings if the file is not modifiable
164 let b:statusline_tab_warning = ''
165
166 if !&modifiable
167 return b:statusline_tab_warning
168 endif
169
d2bd0034 »
2008-11-02 update statusline hax
170 let tabs = search('^\t', 'nw') != 0
9f5a0fdc »
2008-10-29 maket the tab warning on the stl own more
171
01e5c6e4 »
2010-07-01 another fix to the intent stl flag
172 "find spaces that arent used as alignment in the first indent column
173 let spaces = search('^ \{' . &ts . ',}[^\t]', 'nw') != 0
3ae194e8 »
2010-06-29 upgrade the statsline indent warning
174
9f5a0fdc »
2008-10-29 maket the tab warning on the stl own more
175 if tabs && spaces
01e5c6e4 »
2010-07-01 another fix to the intent stl flag
176 let b:statusline_tab_warning = '[mixed-indenting]'
9f5a0fdc »
2008-10-29 maket the tab warning on the stl own more
177 elseif (spaces && !&et) || (tabs && &et)
178 let b:statusline_tab_warning = '[&et]'
179 endif
03cf502e »
2008-10-28 make the statusline own harder
180 endif
9f5a0fdc »
2008-10-29 maket the tab warning on the stl own more
181 return b:statusline_tab_warning
03cf502e »
2008-10-28 make the statusline own harder
182 endfunction
183
0596fefb »
2009-06-18 add a statusline warning if long lines are detected
184 "recalculate the long line warning when idle and after saving
185 autocmd cursorhold,bufwritepost * unlet! b:statusline_long_line_warning
186
dcfd9218 »
2009-06-26 bugfix and awesomify the long line warning
187 "return a warning for "long lines" where "long" is either &textwidth or 80 (if
188 "no &textwidth is set)
189 "
190 "return '' if no long lines
d47587e2 »
2009-06-28 decompose the statusline long line warning function
191 "return '[#x,my,$z] if long lines are found, were x is the number of long
192 "lines, y is the median length of the long lines and z is the length of the
193 "longest line
0596fefb »
2009-06-18 add a statusline warning if long lines are detected
194 function! StatuslineLongLineWarning()
195 if !exists("b:statusline_long_line_warning")
b4ad446a »
2010-07-01 supress statusbar warnings if the file is not modifiable
196
197 if !&modifiable
198 let b:statusline_long_line_warning = ''
199 return b:statusline_long_line_warning
200 endif
201
d47587e2 »
2009-06-28 decompose the statusline long line warning function
202 let long_line_lens = s:LongLines()
0596fefb »
2009-06-18 add a statusline warning if long lines are detected
203
e2ef6c82 »
2009-06-28 make the long line warning more awesome
204 if len(long_line_lens) > 0
d47587e2 »
2009-06-28 decompose the statusline long line warning function
205 let b:statusline_long_line_warning = "[" .
206 \ '#' . len(long_line_lens) . "," .
207 \ 'm' . s:Median(long_line_lens) . "," .
208 \ '$' . max(long_line_lens) . "]"
0596fefb »
2009-06-18 add a statusline warning if long lines are detected
209 else
210 let b:statusline_long_line_warning = ""
211 endif
212 endif
213 return b:statusline_long_line_warning
214 endfunction
215
d47587e2 »
2009-06-28 decompose the statusline long line warning function
216 "return a list containing the lengths of the long lines in this buffer
217 function! s:LongLines()
218 let threshold = (&tw ? &tw : 80)
219 let spaces = repeat(" ", &ts)
220
221 let long_line_lens = []
222
223 let i = 1
224 while i <= line("$")
225 let len = strlen(substitute(getline(i), '\t', spaces, 'g'))
226 if len > threshold
227 call add(long_line_lens, len)
228 endif
229 let i += 1
230 endwhile
231
232 return long_line_lens
233 endfunction
234
e2ef6c82 »
2009-06-28 make the long line warning more awesome
235 "find the median of the given array of numbers
236 function! s:Median(nums)
237 let nums = sort(a:nums)
238 let l = len(nums)
239
240 if l % 2 == 1
241 let i = (l-1) / 2
242 return nums[i]
243 else
244 return (nums[l/2] + nums[(l/2)-1]) / 2
245 endif
246 endfunction
247
2f51cb25 »
2011-02-08 rearrange my vimrc and move some stuff in from my actual ~/.vimrc
248 "syntastic settings
249 let g:syntastic_enable_signs=1
6dd24573 »
2011-02-27 show one file in taglist
250 let g:syntastic_auto_loc_list=2
2f51cb25 »
2011-02-08 rearrange my vimrc and move some stuff in from my actual ~/.vimrc
251
252 "snipmate settings
253 let g:snips_author = "Martin Grenfell"
254
255 "taglist settings
256 let Tlist_Compact_Format = 1
257 let Tlist_Enable_Fold_Column = 0
258 let Tlist_Exit_OnlyWindow = 0
259 let Tlist_WinWidth = 35
260 let tlist_php_settings = 'php;c:class;f:Functions'
261 let Tlist_Use_Right_Window=1
262 let Tlist_GainFocus_On_ToggleOpen = 1
263 let Tlist_Display_Tag_Scope = 1
264 let Tlist_Process_File_Always = 1
6dd24573 »
2011-02-27 show one file in taglist
265 let Tlist_Show_One_File = 1
2f51cb25 »
2011-02-08 rearrange my vimrc and move some stuff in from my actual ~/.vimrc
266
267 "nerdtree settings
268 let g:NERDTreeMouseMode = 2
269 let g:NERDTreeWinSize = 40
270
271 "explorer mappings
272 nnoremap <f1> :BufExplorer<cr>
273 nnoremap <f2> :NERDTreeToggle<cr>
274 nnoremap <f3> :TlistToggle<cr>
275
276 "source project specific config files
277 runtime! projects/**/*.vim
63af46f3 »
2008-09-21 add the useful parts of my vimrc
278
332c6778 »
2008-10-07 dont source csapprox if we dont have gui support
279 "dont load csapprox if we no gui support - silences an annoying warning
280 if !has("gui")
281 let g:CSApprox_loaded = 1
282 endif
283
63af46f3 »
2008-09-21 add the useful parts of my vimrc
284 "make <c-l> clear the highlight as well as redraw
285 nnoremap <C-L> :nohls<CR><C-L>
286 inoremap <C-L> <C-O>:nohls<CR>
287
288 "map Q to something useful
289 noremap Q gq
290
291 "make Y consistent with C and D
292 nnoremap Y y$
293
294 "visual search mappings
295 function! s:VSetSearch()
296 let temp = @@
297 norm! gvy
298 let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g')
299 let @@ = temp
300 endfunction
301 vnoremap * :<C-u>call <SID>VSetSearch()<CR>//<CR>
302 vnoremap # :<C-u>call <SID>VSetSearch()<CR>??<CR>
303
304
f170376c »
2008-09-23 add some more to the vimrc
305 "jump to last cursor position when opening a file
306 "dont do it when writing a commit log entry
63af46f3 »
2008-09-21 add the useful parts of my vimrc
307 autocmd BufReadPost * call SetCursorPosition()
308 function! SetCursorPosition()
08b6a53d »
2010-09-09 dont change the cursor position for svn files
309 if &filetype !~ 'svn\|commit\c'
63af46f3 »
2008-09-21 add the useful parts of my vimrc
310 if line("'\"") > 0 && line("'\"") <= line("$")
f5bd12f3 »
2009-06-08 use normal! and center screen when restoring cursor position
311 exe "normal! g`\""
312 normal! zz
63af46f3 »
2008-09-21 add the useful parts of my vimrc
313 endif
314 end
315 endfunction
316
b7420f56 »
2011-02-06 enable spell check when writing commit logs
317 "spell check when writing commit logs
318 autocmd filetype svn,*commit* set spell
Something went wrong with that request. Please try again.