Skip to content
Newer
Older
100644 871 lines (756 sloc) 26.1 KB
9ce3167 @kennethlove updates to .vimrc, removed yankring history and added it to the ignor…
kennethlove authored May 11, 2010
1 set nocompatible
2 set cpoptions=aABceFsmq
3 set autochdir
4 set nostartofline " don't jump to the first character when paging
5 set title
6 set backspace=indent,eol,start " allow backspacing over everything in insert mode
7 set nowb
8 set noswapfile
9 set ttyfast
771f909 @kennethlove changes to .vimrc
kennethlove authored May 12, 2010
10 let mapleader = ','
11 let g:mapleader = ','
150f752 @kennethlove updates to .vimrc/.gvimrc files. added pydiction plugin. deleted .DS_…
kennethlove authored May 18, 2010
12 let localleader = ','
13 let g:localleader = ','
14 let leader = ','
15 let g:leader = ','
5f55b6b @kennethlove initial
kennethlove authored May 11, 2010
16
9ce3167 @kennethlove updates to .vimrc, removed yankring history and added it to the ignor…
kennethlove authored May 12, 2010
17 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
18 " DISPLAY
19 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
20 set ruler
21 set number
22 set showcmd
23 set laststatus=2
24 set complete=.,w,b,u,U,t,i,d,s,k
25 filetype plugin indent on
26 set winminheight=0
27 set winminwidth=0
28 set winheight=10
29 set display+=lastline
30 set textwidth=0
31 set columns=90
32 set wrapmargin=10
33 set numberwidth=5
34
35 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
36 " BEHAVIOR
37 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
38 set autoread
39 set noautowrite
40 set visualbell
41 set t_vb= " visual bell
42 set shellcmdflag=-c
43 set shell=bash\ -l
44 set modeline
45 set modelines=5
46 set tabpagemax=100
47 set mousemodel=extend
48 set noea
49 set shortmess=aOstT " shortens messages to avoid 'press a key' prompt
50 set magic
51 set viminfo='10,\"100,:20,%,n~/.viminfo
52 set confirm
53 set report=0
54 set smartcase
55
56 " Saving sessions
57 set sessionoptions=blank,buffers,curdir,folds,globals,help,localoptions,options,resize,tabpages,winsize,winpos
58
59 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
60 " TEXT EDITING
61 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
62 set imd
63 set wildmenu
64 set wildmode=list:longest,full
65 set wildignore+=*.o,*~,.lo
66 set iskeyword+=$,@,%,# " none of these are word dividers
35ce71e @kennethlove removed unused plugins. added testing to .vimrc for python files/djan…
kennethlove authored Jun 14, 2010
67 set iskeyword-=_,. " these are word dividers
9ce3167 @kennethlove updates to .vimrc, removed yankring history and added it to the ignor…
kennethlove authored May 12, 2010
68 set whichwrap=b,s,h,l,<,>,~,[,] "everything wraps
69 set undolevels=1000
70 set autoindent
71 set preserveindent
72 set nosmartindent
73 set smarttab
74 set expandtab
75 set tabstop=4
76 set softtabstop=4
77 set shiftwidth=4
78 set wrap
79 set formatoptions=lcroqwan2vb1
80 set showmatch
81 set matchtime=5
82 set list
83 " Use the same symbols as TextMate for tabstops and EOLs
84 set listchars=tab:\ ,eol:¬,trail:-
85 set showbreak=…
86 set encoding=utf-8 fileencodings=.
87 set showfulltag
88
89 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
90 " FOLDS
91 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
92 "set foldmethod=indent
93 set foldenable
94 set foldopen=block,hor,mark,percent,quickfix,tag
95 set foldminlines=2
d4b5fd9 @kennethlove updates
kennethlove authored Jun 11, 2010
96 set fillchars+=fold:\
9ce3167 @kennethlove updates to .vimrc, removed yankring history and added it to the ignor…
kennethlove authored May 12, 2010
97
98 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
99 " BUFFERS
100 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
101 au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
102 set bufhidden=hide
103 set hidden " you can change buffers without saving
104 set switchbuf=usetab
105 set splitright
d3d93c5 @kennethlove show line numbers in NERDTree, smaller scroll offset, new statusline
kennethlove authored May 24, 2010
106 set scrolloff=2
107 set sidescrolloff=2
771f909 @kennethlove changes to .vimrc
kennethlove authored May 12, 2010
108 set showtabline=1
9ce3167 @kennethlove updates to .vimrc, removed yankring history and added it to the ignor…
kennethlove authored May 12, 2010
109
110 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
111 " COLORS
112 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
113 syntax on
114 colorscheme wombat256
115 set background=dark
116 hi NonText ctermfg=7 guifg=gray
117 hi SpecialKey ctermfg=8
118
119 " Use the below highlight group when displaying bad whitespace is desired.
3fb1f7e @kennethlove coloring
kennethlove authored Jun 16, 2010
120 highlight ExtraWhitespace ctermbg=red guibg=red
121 match ExtraWhitespace /\s\+$/
122 autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
123 autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
124 autocmd InsertLeave * match ExtraWhitespace /\s\+$/
125 autocmd BufWinLeave * call clearmatches()
9ce3167 @kennethlove updates to .vimrc, removed yankring history and added it to the ignor…
kennethlove authored May 12, 2010
126
127 " full Python syntax highlighting
128 let python_highlight_all=1
129
130 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
131 " STATUS LINE
132 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
133 set laststatus=2
3ff59ac @kennethlove functions to show bad whitespace and long lines
kennethlove authored Jun 23, 2010
134
135 set statusline=%-.50F " Full path to file, 50 characters max
136 set statusline+=\ (%n) " buffer number
137 set statusline+=\ %([%M%R%H%W]\ %) " Modified, Read-only, Help, and Preview flags
138 set statusline+=\ %y " Filetype
139 set statusline+=\ %#error# " switch to error color
140 set statusline+=%{StatuslineTabWarning()} " show warning about mixed tabs or bad &et
141 set statusline+=%{StatuslineTrailingSpaceWarning()} " show warning about trailing whitespace
142 set statusline+=%{StatuslineLongLineWarning()} " show warning about long lines
143 set statusline+=%* " back to normal color
144 set statusline+=\ %#warningmsg# " switch to warningmsg color
145 set statusline+=%{SyntasticStatuslineFlag()} " show Syntastic flag
146 set statusline+=%* " back to normal color
147 set statusline+=\ %=%< " Right-align and start truncation
148 set statusline+=%{TagInStatusLine()} " Show current class/function in Python
149 set statusline+=\ [%04l/%04L\ %03c] " Show current line number, total lines, current column
150 set statusline+=\ %p%% " Percentage through file in lines
151
152 " recalculate the warning flags when idle and after writing
153 autocmd cursorhold,bufwritepost * unlet! b:statusline_tab_warning
154 autocmd cursorhold,bufwritepost * unlet! b:statusline_trailing_space_warning
155 autocmd cursorhold,bufwritepost * unlet! b:statusline_long_line_warning
156
157 " return '[&et]' if &et is set wrong
158 " return '[mixed]' if spaces and tabs are used to indent
159 " return an empty string if everything is fine
160 function! StatuslineTabWarning()
161 if !exists("b:statusline_tab_warning")
162 let tabs = search('^\t', 'nw') != 0
163 let spaces = search('^ ', 'nw') != 0
164
165 if tabs && spaces
166 let b:statusline_tab_warning = '[mixed]'
167 elseif (spaces && !&et) || (tabs && !&et)
168 let b:statusline_tab_warning = '[&et]'
169 else
170 let b:statusline_tab_warning = ''
171 endif
172 endif
173 return b:statusline_tab_warning
174 endfunction
175
176 " return '[\s]' if trailing white space is detected
177 " return '' otherwise
178 function! StatuslineTrailingSpaceWarning()
179 if !exists("b:statusline_trailing_space_warning")
180 let tabs = search('\t\+$', 'nw') != 0
181 let spaces = search('\s\+$', 'nw') != 0
182 if tabs || spaces
183 let b:statusline_trailing_spaces_warning = '[\s]'
184 else
185 let b:statusline_trailing_spaces_warning = ''
186 endif
187 endif
188 return b:statusline_trailing_spaces_warning
189 endfunction
190
191 " return a warning for 'long lines' where 'long' is either &textwidth
192 " or 80 (if no &textwidth is set)
193 "
194 " return '' if no long lines
195 " return '[#x, my, $z]' if long lines are found, where 'x' is the number
196 " of long lines, 'y' is the median length of the long lines, and 'z' is
197 " the length of the longest line
198 function! StatuslineLongLineWarning()
199 if !exists("b:statusline_long_line_warning")
200 let long_line_lens = s:LongLines()
201
202 if len(long_line_lens) > 0
203 let b:statusline_long_line_warning = "[" .
204 \ '#' . len(long_line_lens) . ", " .
205 \ 'm' . s:Median(long_line_lens) . ", " .
206 \ '$' . max(long_line_lens) . "]"
207 else
208 let b:statusline_long_line_warning = ''
209 endif
210 endif
211 return b:statusline_long_line_warning
212 endfunction
213
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
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
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
245
246 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
247 " BACKUPS
248 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
249 silent execute '!mkdir -p ~/.vim_backups'
250 set backupdir=~/.vim_backups//
251 set directory=~/.vim_backups//
252 if has("vms")
253 set nobackup
254 else
255 set backup
256 endif
771f909 @kennethlove changes to .vimrc
kennethlove authored May 12, 2010
257 set nowb
258 set noswapfile
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
259 set viminfo=%100,'100,/100,h,\"500,:100,n~/.viminfo
260 set history=500
261 set updatecount=100
262
263 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
264 " SPELLING
265 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
266 if v:version >= 700
267 setlocal spell spelllang=en_us
268 nmap <LocalLeader>ss :set spell!<CR>
269 endif
771f909 @kennethlove changes to .vimrc
kennethlove authored May 12, 2010
270 try
271 lang en_US
272 catch
273 endtry
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
274
275 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
276 " SEARCH
277 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
278 set incsearch " do incremental searching
279 set ignorecase
280 set infercase
281 set hlsearch
282 set showmatch
283 set diffopt=filler,iwhite
284
285 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
771f909 @kennethlove changes to .vimrc
kennethlove authored May 12, 2010
286 " COMMAND-LINE
287 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
288 cno $q <C-\>eDeleteTilSlash()<CR>
289
290 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
291 " SETTINGS PER FILETYPE
292 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
293 if has("autocmd")
294 " Enable file type detection
295 filetype plugin indent on
296
297 " Syntax of these languages is fussy over tabs Vs spaces
298 autocmd FileType make setlocal ts=8 sts=8 sw=8 noexpandtab
299 autocmd FileType yaml setlocal ts=4 sts=4 sw=4 expandtab
300
301 " Customisations based on house-style (arbitrary)
302 autocmd FileType html setlocal ts=4 sts=4 sw=4 noexpandtab
303 autocmd FileType xhtml setlocal ts=4 sts=4 sw=4 noexpandtab
304 autocmd FileType html.django_template setlocal ts=4 sts=4 sw=4 noexpandtab
305 autocmd FileType htmldjango setlocal ts=4 sts=4 sw=4 noexpandtab
306 autocmd FileType css setlocal ts=2 sts=2 sw=2 expandtab
307 autocmd FileType javascript setlocal ts=4 sts=4 sw=4 noexpandtab
771f909 @kennethlove changes to .vimrc
kennethlove authored May 12, 2010
308 autocmd FileType python setlocal ts=4 sts=4 sw=4 expandtab nocindent
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
309
310 " Treat .rss files as XML
311 autocmd BufNewFile,BufRead *.rss setfiletype xml
312
313 " Automatically strip extraneous whitespace when saving Python or
314 " Javascript files.
315 autocmd BufWritePre *.py,*.js :call <SID>StripTrailingWhitespaces()
316
317 " markdown
318 augroup mkd
319 autocmd BufRead *.mkd set ai formatoptions=tcroqn2 comments=n:>
320 augroup END
321
322 " JSON syntax
323 au! BufRead,BufNewFile *.json setfiletype json
324
325 " jQuery syntax
326 au! BufRead,BufNewFile *.js set ft=javascript.jquery
327
328 " Display tabs at the beginning of a line in Python mode as bad
3fb1f7e @kennethlove coloring
kennethlove authored Jun 17, 2010
329 au BufRead,BufNewFile *.py,*.pyw match ExtraWhitespace /^\t\+/
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
330 " Make trailing whitespace be flagged as bad
3fb1f7e @kennethlove coloring
kennethlove authored Jun 17, 2010
331 au BufRead,BufNewFile *.py,*.pyw match ExtraWhitespace /\s\+$/
332 au BufRead,BufNewFile *.py,*.pyw let python_space_errors = 1
3ff59ac @kennethlove functions to show bad whitespace and long lines
kennethlove authored Jun 23, 2010
333 au BufRead,BufNewfile *.py,*.pyw call s:HighlightLongLines(79)
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
334
335 " only UNIX line endings.
336 au BufNewFile *.* set fileformat=unix
337
338 autocmd BufEnter * :syntax sync fromstart
339
340 " mapping to make HTML files Django-highlighted
771f909 @kennethlove changes to .vimrc
kennethlove authored May 12, 2010
341 autocmd BufEnter *html nmap <F6> :setfiletype htmldjango<CR>
342 autocmd BufEnter *html nmap <S-F6> :setfiletype django<CR>
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
343
344 if version >= 700
345 autocmd FileType python set omnifunc=pythoncomplete#Complete
771f909 @kennethlove changes to .vimrc
kennethlove authored May 12, 2010
346 autocmd FileType css set omnifunc=csscomplete#CompleteCSS
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
347 endif
348
2b71760 @kennethlove autocommands for HTML and css
kennethlove authored Jun 3, 2010
349 " CSS, XML, and HTML file shoulds be folded based on indent
350 au BufNewFile,BufRead *css,*xml,*htm* set foldmethod=indent
351
352 " CSS and Sass files should see - as part of a keyword
353 autocmd FileType css,sass set iskeyword +=-
d4b5fd9 @kennethlove updates
kennethlove authored Jun 11, 2010
354
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
355 endif
356
357
358 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
359 " KEY MAPPINGS
360 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
771f909 @kennethlove changes to .vimrc
kennethlove authored May 12, 2010
361 " CD to directory of current file
362 map <Leader>cd :cd %:p:h<CR>
363
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
364 " Grep/QuickFix window bindings
771f909 @kennethlove changes to .vimrc
kennethlove authored May 12, 2010
365 map <Leader>c :botright cw 10<CR>
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
366
367 " Don't move around in Insert mode
368 inoremap <Left> <Esc><Right><Left>
369 inoremap <Right> <Esc><Right><Right>
370 inoremap <Up> <Esc><Right><Up>
371 inoremap <Down> <Esc><Right><Down>
372
373 " Easily move chunks of text
374 nnoremap <A-j> :m+<CR>==
375 nnoremap <A-k> :m-2<CR>==
376 inoremap <A-j> <Esc>:m+<CR>==gi
377 inoremap <A-k> <Esc>:m-2<CR>==gi
378 vnoremap <A-j> :m'>+<CR>gv=gv
379 vnoremap <A-k> :m-2<CR>gv=gv
380
381 " Mac OS X/Safari keybindings for tabs
382 nmap <D-[> :tabprevious<CR>
383 nmap <D-]> :tabnext<CR>
384 map <D-[> :tabprevious<CR>
385 map <D-]> :tabnext<CR>
386 imap <D-[> <Esc>:tabprevious<CR>i
387 imap <D-]> <Esc>:tabnext<CR>i
388 nmap <D-t> :tabnew<CR>
389 imap <D-t> <Esc>:tabnew<CR>
390
391 " Bind Command-arrow/movement to move between windows
392 map <D-J> <C-W>j
393 map <D-S-Down> <C-W>j
394 map <D-K> <C-W>k
395 map <D-S-Up> <C-W>k
396 map <D-H> <C-W>h
397 map <D-S-Left> <C-W>h
398 map <D-L> <C-W>l
399 map <D-S-Right> <C-W>l
400
3ff59ac @kennethlove functions to show bad whitespace and long lines
kennethlove authored Jun 23, 2010
401 map <D-0> <C-W>= " make Command-0 equal windows
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
402
403 " If I forgot to sudo a file, do that with :w!!
404 cmap w!! %!sudo tee > /dev/null %
405
406 " Don't use Ex mode, use Q for formatting
407 nmap Q gq
408
409 " Turn hidden characters on/off
410 nmap <silent> <LocalLeader>s :set nolist!<CR>
411
412 " Up/down go visually instead of by physical lines
413 " Interactive ones need to check whether we're in the autocomplete popup
414 map <up> gk
d4b5fd9 @kennethlove updates
kennethlove authored Jun 11, 2010
415 "inoremap <up> <C-R>=pumvisible() ? "\<lt>up>" : "\<lt>C-o>gk"<Enter>
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
416 map <down> gj
d4b5fd9 @kennethlove updates
kennethlove authored Jun 11, 2010
417 "inoremap <down> <C-R>=pumvisible() ? "\<lt>down>" : "\<lt>C-o>gj"<Enter>
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
418
419 " Map normal mode Enter to add a new line before the current one
420 nmap <Enter> O<Esc>
421
422 " map F1 to open previous buffer
423 map <F1> :previous<CR>
424 " map F2 to open next buffer
425 map <F2> :next<CR>
426 " fast open a buffer by search for a name
427 map <c-q> :sb
428
429 " Makes W send w when it's a command
430 command! W w
431
432 " bind command-]/command-[ to act like TextMate
433 nmap <D-]> >>
434 nmap <D-[> <<
435 vmap <D-]> >gv
436 vmap <D-[> <gv
437
771f909 @kennethlove changes to .vimrc
kennethlove authored May 12, 2010
438 " Toggle search highlight
439 nnoremap <silent> <Leader>ts :silent :set invhlsearch<CR>:set hlsearch?<CR>
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
440
441 " Folds
442 nnoremap <silent> <Space> @=(foldlevel('.')?'za':'l')<CR>
443 " set <space> to toggle folds in normal & visual modes
444 nnoremap <space> za
445 vnoremap <space> zf
446
447 " Searching
448 nmap n nzzzv
449 nmap N Nzzzv
450 nmap * *zzzv
451 nmap # #zzzv
452 nmap g* g*zzzv
453 nmap g# g#zzzv
454
771f909 @kennethlove changes to .vimrc
kennethlove authored May 12, 2010
455 " Parenthesis/bracket expanding
456 vnoremap $1 <esc>`>a)<esc>`<i(<esc>
457 vnoremap $2 <esc>`>a]<esc>`<i[<esc>
458 vnoremap $3 <esc>`>a}<esc>`<i{<esc>
459 vnoremap $$ <esc>`>a"<esc>`<i"<esc>
460 vnoremap $q <esc>`>a'<esc>`<i'<esc>
461 vnoremap $e <esc>`>a"<esc>`<i"<esc>
462
463 " Map auto complete of (, ", ', [
464 inoremap $1 ()<esc>i
465 inoremap $2 []<esc>i
466 inoremap $3 {}<esc>i
467 inoremap $4 {<esc>o}<esc>O
468 inoremap $q ''<esc>i
469 inoremap $e ""<esc>i
470
471 " Mappings for cope
472 map <leader>cc :botright cope<CR>
473 map <leader>n :cn<CR>
474 map <leader>p :cp<CR>
0d39e09 @kennethlove re-added the signs check for syntastic
kennethlove authored Jun 23, 2010
475 map <leader>ll :ll<CR>
771f909 @kennethlove changes to .vimrc
kennethlove authored May 12, 2010
476
d4b5fd9 @kennethlove updates
kennethlove authored Jun 11, 2010
477 " Mapping for tabs/buffers
478 map gz :bdelete<CR>
479 map gb :bnext<CR>
480 map gB :bprev<CR>
481
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
482 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
483 " PLUGIN SETTINGS
484 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
485
150f752 @kennethlove updates to .vimrc/.gvimrc files. added pydiction plugin. deleted .DS_…
kennethlove authored May 18, 2010
486 " PyDiction
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
487 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
150f752 @kennethlove updates to .vimrc/.gvimrc files. added pydiction plugin. deleted .DS_…
kennethlove authored May 18, 2010
488 let g:pydiction_location="/Users/kennethlove/.vim/ftplugin/python/pydiction/complete-dict"
489 if has("autocmd")
490 autocmd FileType python set complete+=k/Users/kennethlove/.vim/ftplugin/python/pydiction iskeyword+=.,(
491 endif
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
492
493 " MATCHIT
494 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
495 runtime plugins/matchit.vim
496 let b:match_ignorecase = 1
497
498 " NETRW
499 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
500 " Default to tree view
501 let g:netrw_lifestyle = 3
502 " hide common hidden files
503 let g:netrw_list_hide = '.*\.py[co]$,\.git$,\.swp$'
504 " Don't use fricken elinks, wtf
505 let g:netrw_http_cmd = "wget -q -O" " or 'curl -Ls -o'
506 let g:netrw_winsize = 10
507 let g:netrw_alto = 1
508
509 " PROJECT
510 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
511 nmap <silent> <Leader>P :Project<CR>
512 let g:proj_window_width = 30
513 let g:proj_window_increment = 15
514 let g:proj_flags = "istbcLST"
515
516 " LUSTYJUGGLER
517 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
518 let g:LustyJugglerSuppressRubyWarning = 1
519
35ce71e @kennethlove removed unused plugins. added testing to .vimrc for python files/djan…
kennethlove authored Jun 14, 2010
520 " EASYTAGS
521 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
522 let g:easytags_resolve_links = 1
3fb1f7e @kennethlove coloring
kennethlove authored Jun 17, 2010
523 let g:easytags_cmd = '/usr/local/bin/ctags'
35ce71e @kennethlove removed unused plugins. added testing to .vimrc for python files/djan…
kennethlove authored Jun 14, 2010
524
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
525 " TAGLIST
526 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3fb1f7e @kennethlove coloring
kennethlove authored Jun 17, 2010
527 let Tlist_Use_Right_Window = 1
528 let Tlist_Auto_Open = 0
529 let Tlist_Enable_Fold_Column = 0
530 let Tlist_Compact_Format = 1
531 let Tlist_WinWidth = 40
532 let Tlist_Exit_OnlyWindow = 1
533 let Tlist_File_Fold_Auto_Close = 1
534 let Tlist_Sort_Type = 'name'
535 let Tlist_Ctags_Cmd = '/usr/local/bin/ctags'
536 let Tlist_Show_Menu = 1
537 let Tlist_GainFocus_On_ToggleOpen = 1
538 let Tlist_Close_On_Select = 1
539 let Tlist_Auto_Update = 1
35ce71e @kennethlove removed unused plugins. added testing to .vimrc for python files/djan…
kennethlove authored Jun 14, 2010
540 nnoremap <silent> <Leader>t :TlistToggle<CR>
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
541
542 " RAGTAG
543 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
544 inoremap <M-o> <Esc>o
545 inoremap <C-j> <Down>
546 let g:ragtag_global_maps = 1
547
548 " NERD_COMMENTER
549 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
550 nmap <D-/> ,c<space>
551 vmap <D-/> ,c<space>
552 imap <D-/> <C-O>,c<space>
553
554 " NERD_TREE
555 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
e78083e @kennethlove clean up and most up-to-date syntastic
kennethlove authored Jun 23, 2010
556 nmap <Leader>d :NERDTreeToggle<CR>
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
557 let g:NERDChristmasTree = 1
558 let g:NERDTreeQuitOnOpen = 1
559 let g:NERDTreeWinPos = 'right'
560 let g:NERDTreeChDirMode = 2
561 let g:NERDTreeShowHidden = 1
562 let g:NERDTreeAutoCenter = 1
563 let g:NERDTreeIgnore = ['\.git$', '\.svn$', '\.jpg$', '\.gif$', '\.png$', '\.pyc', '\.DS_Store']
564 let g:NERDTreeShowBookmarks = 1
565 let g:NERDTreeSortOrder = ['\/$', '*']
d3d93c5 @kennethlove show line numbers in NERDTree, smaller scroll offset, new statusline
kennethlove authored May 24, 2010
566 let g:NERDTreeShowLineNumbers = 1
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
567
568 " YANKRING
569 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
570 nnoremap <silent> <Leader>y :YRShow<CR>
571 "
572 " skip all single-letter deletes (x)
573 let g:yankring_min_element_length = 2
574 "
575 " save last 50 items in history, only show last 50 in window
576 let g:yankring_max_history = 50
577 let g:yankring_max_display = 50
578 "
579 " save yankring entries across vim instances
580 let g:yankring_persist = 1
581 let g:yankring_share_between_instances = 1
582 "
583 " don't save duplicates
584 let g:yankring_ignore_duplicate = 1
585
586 " use a separate vertical split window that auto-closes and
587 " is 30 chars wide on the right side
588 let g:yankring_window_use_separate = 1
589 let g:yankring_window_use_horiz = 0
590 let g:yankring_window_auto_close = 1
591 let g:yankring_window_width = 50
592 let g:yankring_window_use_right = 1
593
594 " pressing <space> will increase the size of the window by 15 columns
595 let g:yankring_window_increment = 15
596
597 " have yankring manage Vim's numbered registers ("0-"9)
598 let g:yankring_manage_numbered_reg = 1
599
600 " keep the history file in the $HOME/.vim folder instead of $HOME
601 let g:yankring_history_dir = '$HOME/.vim'
602
603 " yankring keeps an eye on the clipboard
604 let g:yankring_clipboard_monitor = 1
605
606 " if something changes the default register without going through
607 " yankring, use the default register value rather than the top item in
608 " yankring's history
609 let g:yankring_paste_check_default_buffer = 1
610
611 " SYNTASTIC
612 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
613 " use signs to indicate lines with errors
614 " only if signs are available
0d39e09 @kennethlove re-added the signs check for syntastic
kennethlove authored Jun 23, 2010
615 if has('signs')
616 let g:syntastic_enable_signs = 1
617 endif
618 "let g:syntastic_enable_signs = 1
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
619
620 " automatically open the location list when a buffer has errors
621 let g:syntastic_auto_loc_list = 1
622
623 " always show warnings
624 let g:syntastic_quiet_warnings = 0
625
626 " ignore djangohtml
e78083e @kennethlove clean up and most up-to-date syntastic
kennethlove authored Jun 23, 2010
627 "let g:syntastic_disabled_filetypes = ['html', 'txt', 'text', 'tumblr', 'css']
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
628
629 " FUGITIVE
630 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
631 nmap <Leader>gs :Gstatus<CR>
632 nmap <Leader>gc :Gcommit<CR>
633
634 " SCRATCH BUFFER
635 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
150f752 @kennethlove updates to .vimrc/.gvimrc files. added pydiction plugin. deleted .DS_…
kennethlove authored May 18, 2010
636 nmap <Leader>S :Sscratch<CR>
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
637
638 " BUFEXPLORER
639 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
640 let g:bufExplorerSortBy = 'mru'
641 let g:bufExplorerSplitBelow = 1
642 let g:bufExplorerSplitRight = 1
771f909 @kennethlove changes to .vimrc
kennethlove authored May 12, 2010
643 let g:bufExplorerDefaultHelp = 0
644 let g:bufExplorerShowRelativePath = 1
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
645
646 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3ff59ac @kennethlove functions to show bad whitespace and long lines
kennethlove authored Jun 23, 2010
647 " FUNCTIONS
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
648 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
649
3ff59ac @kennethlove functions to show bad whitespace and long lines
kennethlove authored Jun 23, 2010
650 " HIGHLIGHT LONG LINES
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
651 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3ff59ac @kennethlove functions to show bad whitespace and long lines
kennethlove authored Jun 23, 2010
652 command! -nargs=? HighlightLongLines call s:HighlightLongLines('<args>')
653 function! s:HighlightLongLines(width)
654 let targetWidth = a:width != '' ? a:width : 79
655 if targetWidth > 0
656 exec 'match Error /\%>' . (targetWidth) . 'v/'
657 else
658 echomsg "Usage: HighlightLongLines [natural number]"
659 endif
660 endfunction
1370b6a @kennethlove updates
kennethlove authored Jun 23, 2010
661 nmap <leader>h :HighlightLongLines<CR>
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
662
663 " CREATE WORDPROCESSING MODE
664 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
665 cabbr wp call Wp()
666 fun! Wp()
667 set lbr
668 source /Users/kennethlove/.vim/autocorrect/autocorrect.vim
669 set nonumber
670 set spell spelllang=en_us
671 endfu
672
673 " SEARCH FOR VISUAL SELECTION
674 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3723edb @kennethlove new visual search function and better nerdtree map
kennethlove authored Jun 23, 2010
675 function! s:VSetSearch()
676 let temp = @@
677 norm! gvy
678 let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g')
679 let @@ = temp
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
680 endfunction
681
3723edb @kennethlove new visual search function and better nerdtree map
kennethlove authored Jun 23, 2010
682 vnoremap * :<C-u>call <SID>VSetSearch()<CR>//<CR>
683 vnoremap # :<C-u>call <SID>VSetSearch()<CR>??<CR>
684
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
685 " STAB: SET TABSTOPS
686 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
687 " Set tabstop, softtabstop and shiftwidth to the same value
688 command! -nargs=* Stab call Stab()
689 function! Stab()
690 let l:tabstop = 1 * input('set tabstop = softtabstop = shiftwidth = ')
691 if l:tabstop > 0
692 let &l:sts = l:tabstop
693 let &l:ts = l:tabstop
694 let &l:sw = l:tabstop
695 endif
696 call SummarizeTabs()
697 endfunction
698
699 function! SummarizeTabs()
700 try
701 echohl ModeMsg
702 echon 'tabstop='.&l:ts
703 echon ' shiftwidth='.&l:sw
704 echon ' softtabstop='.&l:sts
705 if &l:et
706 echon ' expandtab'
707 else
708 echon ' noexpandtab'
709 end
710 finally
711 echohl None
712 endtry
713 endfunction
714
715 " STRIP TRAILING WHITESPACE
716 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
717 function! <SID>StripTrailingWhitespaces()
718 " Preparation: save last search, and cursor position.
719 let _s=@/
720 let l = line(".")
721 let c = col(".")
722 " Do the business:
723 %s/\s\+$//e
724 " Clean up: restore previous search history, and cursor position
725 let @/=_s
726 call cursor(l, c)
727 endfunction
728
729 nnoremap <silent> <F5> :call <SID>StripTrailingWhitespaces()<CR>
730
731 " DISPLAY OUTPUT OF SHELL COMMANDS IN SCRATCH BUFFER
732 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
733 command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(<q-args>)
734 function! s:RunShellCommand(cmdline)
735 let isfirst = 1
736 let words = []
737 for word in split(a:cmdline)
738 if isfirst
739 let isfirst = 0 " don't change first word (shell command)
740 else
741 if word[0] =~ '\v[%#<]'
742 let word = expand(word)
743 endif
744 let word = shellescape(word, 1)
745 endif
746 call add(words, word)
747 endfor
748 let expanded_cmdline = join(words)
749 botright new
750 setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap
751 silent execute '$read !'. expanded_cmdline
752 1
753 endfunction
754
771f909 @kennethlove changes to .vimrc
kennethlove authored May 12, 2010
755 func! Cwd()
756 let cwd = getcwd()
757 return "e " . cwd
758 endfunc
759
760 func! DeleteTilSlash()
761 let g:cmd = getcmdline()
762 let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*", "\\1", "")
763 if g:cmd == g:cmd_edited
764 let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*/", "\\1", "")
765 endif
766 return g:cmd_edited
767 endfunc
768
769 func! CurrentFileDir(cmd)
770 return a:cmd . " " . expand("%:p:h") . "/"
771 endfunc
772
773 func! CurDir()
774 let curdir = substitute(getcwd(), '/Users/kennethlove', "~/", "g")
775 return curdir
776 endfunc
5f55b6b @kennethlove initial
kennethlove authored May 12, 2010
777
778 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
779 " MISCELLANEOUS
780 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
781 " This beauty remembers where you were the last time you edited the file, and returns to the same position.
782 au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
783
35ce71e @kennethlove removed unused plugins. added testing to .vimrc for python files/djan…
kennethlove authored Jun 14, 2010
784 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
785 " TESTING
786 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
787 let g:makeprg_django_app = 'python\ manage.py\ test'
788 let g:makeprg_django_project = 'python\ manage.py\ test'
789 set errorformat=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m
d4b5fd9 @kennethlove updates
kennethlove authored Jun 11, 2010
790
a9649f0 @kennethlove ack plugin and updates to .vimrc
kennethlove authored Jun 23, 2010
791 command! -nargs=* Manage call GetManageLocation()<CR>
792 function! GetManageLocation()
793 "sitename=`pwd | awk -F\/ '{ print $2 }'`
794 "find /Sites/$sitename -name filename
795 "let sitename = system("pwd | awk -F\/ '{ print $2 }'")
796 let sitename = system("pwd | awk -F\/ '{ print $3 }'")
797 let managepath = substitute("/Sites/%s/", "/\%s/", "sitename")
798 echo managepath
799 endfunction
800
d4b5fd9 @kennethlove updates
kennethlove authored Jun 11, 2010
801 function! RunTestsForFile(args)
35ce71e @kennethlove removed unused plugins. added testing to .vimrc for python files/djan…
kennethlove authored Jun 14, 2010
802 if @% =~ '\.py$'
803 let expandstr = '%:p:h' " dirname
804 while expand(expandstr) != '/'
805 let testpath = expand(expandstr)
806 if len(getfperm(testpath . '/tests')) > 0 || len(getfperm(testpath . '/tests.py')) > 0
807 call RunTests(expand(expandstr . ':t'), a:args)
808 return
809 endif
810 let expandstr .= ':h'
811 endwhile
d4b5fd9 @kennethlove updates
kennethlove authored Jun 11, 2010
812 endif
35ce71e @kennethlove removed unused plugins. added testing to .vimrc for python files/djan…
kennethlove authored Jun 14, 2010
813 call RunTests('', a:args)
d4b5fd9 @kennethlove updates
kennethlove authored Jun 11, 2010
814 endfunction
815
35ce71e @kennethlove removed unused plugins. added testing to .vimrc for python files/djan…
kennethlove authored Jun 14, 2010
816 function! RunTests(target, args)
d4b5fd9 @kennethlove updates
kennethlove authored Jun 11, 2010
817 silent ! echo
818 silent ! echo -e "\033[1;36mRunning all unit tests\033[0m"
819 silent w
35ce71e @kennethlove removed unused plugins. added testing to .vimrc for python files/djan…
kennethlove authored Jun 14, 2010
820 if len(a:target)
821 execute 'set makeprg=' . g:makeprg_django_app
822 else
823 execute 'set makeprg=' . g:makeprg_django_project
824 endif
825 exec "make! " . a:target . " " . a:args
d4b5fd9 @kennethlove updates
kennethlove authored Jun 11, 2010
826 endfunction
827
828 function! JumpToError()
35ce71e @kennethlove removed unused plugins. added testing to .vimrc for python files/djan…
kennethlove authored Jun 14, 2010
829 let has_valid_error = 0
830 for error in getqflist()
831 if error['valid']
832 let has_valid_error = 1
833 break
834 endif
835 endfor
836 if has_valid_error
d4b5fd9 @kennethlove updates
kennethlove authored Jun 11, 2010
837 for error in getqflist()
838 if error['valid']
839 break
840 endif
841 endfor
842 let error_message = substitute(error['text'], '^ *', '', 'g')
843 silent cc!
844 exec ":sbuffer " . error['bufnr']
845 call RedBar()
846 echo error_message
847 else
848 call GreenBar()
849 echo "All tests passed"
850 endif
851 endfunction
852
853 function! RedBar()
854 hi RedBar ctermfg=white ctermbg=red guibg=red
855 echohl RedBar
856 echon repeat(" ",&columns - 1)
857 echohl
858 endfunction
859
860 function! GreenBar()
861 hi GreenBar ctermfg=white ctermbg=green guibg=green
862 echohl GreenBar
863 echon repeat(" ",&columns - 1)
864 echohl
865 endfunction
866
a9649f0 @kennethlove ack plugin and updates to .vimrc
kennethlove authored Jun 23, 2010
867 command! -nargs=* Tests call RunTests('', '')<CR>redraw<CR>call JumpToError()<CR>
868 command! -nargs=* FileTests call RunTestsForFile('--failfast')<CR>redraw<CR>call JumpToError()<CR>
869 "nnoremap <leader>A :call RunTests('', '')<cr>:redraw<cr>:call JumpToError()<cr>
870 "nnoremap <leader>Y :call RunTestsForFile('--failfast')<cr>:redraw<cr>:call JumpToError()<cr>
Something went wrong with that request. Please try again.