My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
" Author: John Anderson (sontek@gmail.com)
" Modificacions: Antoni Aloy (aaloy@apsl.net)
" Afegit : http://github.com/skyl/vim-config-python-ide/blob/supertab/.vimrc
" Afegit : http://code.google.com/p/pycopia/source/browse/trunk/vim/vimfiles/vimrc.vim
" Tested with vim7
"
" 5/04/2010 - Added tComment from http://www.vim.org/scripts/script.php?script_id=1173
" - Added better tab completion (test shift+tab)
" - Added markdown syntax
" - Added additional colour themes
" 5/04/2010 - Merged with http://amix.dk/vim/vimrc.html
"
set encoding=utf-8
set ffs=unix,dos,mac "Default file types

" Establim els amples de tabulació

au BufRead,BufNewFile *.py set ai sw=4 sts=4 et tw=72 " Doc strs
au BufRead,BufNewFile *.js set ai sw=2 sts=2 et tw=72 " Doc strs
au BufRead,BufNewFile *.html set ai sw=2 sts=2 et tw=72 " Doc strs
au BufRead,BufNewFile *.json set ai sw=4 sts=4 et tw=72 " Doc strs
au BufNewFile *.html,*.py,*.pyw,*.c,*.h,*.json set fileformat=unix
au! BufRead,BufNewFile *.json setfiletype json

let python_highlight_all=1
syntax on

" Bad whitespace
highlight BadWhitespace ctermbg=red guibg=red
" Display tabs at the beginning of a line in Python mode as bad.
au BufRead,BufNewFile *.py,*.pyw match BadWhitespace /^\t\+/
" Make trailing whitespace be flagged as bad.
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/

filetype plugin on
set iskeyword+=.

"" Skip this file unless we have +eval
if 1

""" Settings
set nocompatible " Don't be compatible with vi

"""" Movement
" work more logically with wrapped lines
noremap j gj
noremap k gk

"""" Searching and Patterns
set ignorecase " search is case insensitive
set smartcase " search case sensitive if caps on
set incsearch " show best match so far
set hlsearch " Highlight matches to the search

"""" Display
set background=dark " I use dark background
set lazyredraw " Don't repaint when scripts are running
set scrolloff=3 " Keep 3 lines below and above the cursor
set ruler " line numbers and column the cursor is on
set number " Show line numbering
set numberwidth=1 " Use 1 col + 1 space for numbers
set ttyfast

if has("gui_running")
syntax enable
set t_Co=256
set hlsearch
set clipboard=autoselect
set guioptions+=T
set toolbar=icons,tooltips
colorscheme wombat "or blackboard
set guifont=DejaVu\ Sans\ Mono
set nu
else
colorscheme tango
endif


" tab labels show the filename without path(tail)
set guitablabel=%N/\ %t\ %M

""" Windows
if exists(":tab") " Try to move to other windows if changing buf
set switchbuf=useopen,usetab
else " Try other windows & tabs if available
set switchbuf=useopen
endif

"""" Messages, Info, Status
set shortmess+=a " Use [+] [RO] [w] for modified, read-only, modified
set showcmd " Display what command is waiting for an operator
set laststatus=2 " Always show statusline, even if only 1 window
set report=0 " Notify me whenever any lines have changed
set confirm " Y-N-C prompt if closing with unsaved changes
set vb t_vb= " Disable visual bell! I hate that flashing.
set statusline=%<%f%m%r%y%=%b\ 0x%B\ \ %l,%c%V\ %P
set laststatus=2 " always a status line


"""" Editing
set backspace=2 " Backspace over anything! (Super backspace!)
set matchtime=2 " For .2 seconds
set formatoptions-=tc " I can format for myself, thank you very much
set nosmartindent
set autoindent
set cindent
set tabstop=4 " Tab stop of 4
set shiftwidth=4 " sw 4 spaces (used on auto indent)
set softtabstop=4 " 4 spaces as a tab for bs/del
set matchpairs+=<:> " specially for html
set showmatch " Briefly jump to the previous matching parent


"""" Coding
set history=100 " 100 Lines of history
set showfulltag " Show more information while completing tags
filetype plugin indent on " Let filetype plugins indent for me

" set up tags
set tags=tags;/
set tags+=$HOME/.vim/tags/python.ctags

""""" Folding
set foldmethod=syntax " By default, use syntax to determine folds
set foldlevelstart=99 " All folds open by default

"""" Command Line
set wildmenu " Autocomplete features in the status bar
set wildmode=longest,list
set wildignore=*.o,*.obj,*.bak,*.exe,*.py[co],*.swp,*~

"""" Autocommands
if has("autocmd")
augroup vimrcEx
au!
" In plain-text files and svn commit buffers, wrap automatically at 78 chars
au FileType text,svn setlocal tw=78 fo+=t

" In all files, try to jump back to the last spot cursor was in before exiting
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif

" Use :make to check a script with perl
au FileType perl set makeprg=perl\ -c\ %\ $* errorformat=%f:%l:%m

" Use :make to compile c, even without a makefile
au FileType c,cpp if glob('Makefile') == "" | let &mp="gcc -o %< %" | endif

" Switch to the directory of the current file, unless it's a help file.
au BufEnter * if &ft != 'help' | silent! cd %:p:h | endif

" Insert Vim-version as X-Editor in mail headers
au FileType mail sil 1 | call search("^$")
\ | sil put! ='X-Editor: Vim-' . Version()

" smart indenting for python
au FileType python set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
autocmd BufWritePre *.py normal m`:%s/\s\+$//e ``
set iskeyword+=.,_,$,@,%,#

" allows us to run :make and get syntax errors for our python scripts
au FileType python set makeprg=python\ -c\ \"import\ py_compile,sys;\ sys.stderr=sys.stdout;\ py_compile.compile(r'%')\"
"au FileType python set makeprg=pylint\ -e\

" kill calltip window if we move cursor or leave insert mode
au CursorMovedI * if pumvisible() == 0|pclose|endif
au InsertLeave * if pumvisible() == 0|pclose|endif

autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType python.django set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType htmldjango.html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS

augroup END
endif

"""" Key Mappings
" bind ctrl+space for omnicompletion
inoremap <Nul> <C-x><C-o>
imap <c-space> <C-x><C-o>

" Toggle the tag list bar
nmap <F4> :TlistToggle<CR>
nmap <F8> :NERDTreeToggle<CR>
" tab navigation (next tab) with alt left / alt right
nnoremap <a-right> gt
nnoremap <a-left> gT

" Ctrl + Arrows - Move around quickly
nnoremap <c-up> {
nnoremap <c-down> }
nnoremap <c-right> El
nnoremap <c-down> Bh

" Shift + Arrows - Visually Select text
nnoremap <s-up> Vk
nnoremap <s-down> Vj
nnoremap <s-right> vl
nnoremap <s-left> vh

if &diff
" easily handle diffing
vnoremap < :diffget<CR>
vnoremap > :diffput<CR>
else
" visual shifting (builtin-repeat)
vnoremap < <gv
vnoremap > >gv
endif

" Extra functionality for some existing commands:
" <C-6> switches back to the alternate file and the correct column in the line.
nnoremap <C-6> <C-6>`"

" CTRL-g shows filename and buffer number, too.
nnoremap <C-g> 2<C-g>

" <C-l> redraws the screen and removes any search highlighting.
nnoremap <silent> <C-l> :nohl<CR><C-l>

" Q formats paragraphs, instead of entering ex mode
noremap Q gq

" * and # search for next/previous of selected text when used in visual mode
vnoremap * y/<C-R>"<CR>
vnoremap # y?<C-R>"<CR>

" <space> toggles folds opened and closed
nnoremap <space> za

" <space> in visual mode creates a fold over the marked range
vnoremap <space> zf

" allow arrow keys when code completion window is up
inoremap <Down> <C-R>=pumvisible() ? "\<lt>C-N>" : "\<lt>Down>"<CR>
j
""" Abbreviations
function! EatChar(pat)
let c = nr2char(getchar(0))
return (c =~ a:pat) ? '' : c
endfunc

endif
" Assignam com a compilador per defecte el pylint
autocmd FileType python compiler pylint

"No executam pylint cada vegada, descomentar
let g:pylint_onwrite = 1

" Taglist variables
" Display function name in status bar:
let g:ctags_statusline=1
" Automatically start script
let generate_tags=1
" Displays taglist results in a vertical window:
let Tlist_Use_Horiz_Window=0
" Shorter commands to toggle Taglist display
nnoremap TT :TlistToggle<CR>
map <F4> :TlistToggle<CR>
" Various Taglist diplay config:
let Tlist_Use_Right_Window = 1
let Tlist_Compact_Format = 1
let Tlist_Exit_OnlyWindow = 1
let Tlist_GainFocus_On_ToggleOpen = 1
let Tlist_File_Fold_Auto_Close = 1

" setup file type for snipmate
"--------------------------------------------------------------------------
au FileType python set ft=python.django
au FileType xhtml set ft=htmldjango.html
au FileType html set ft=htmldjango.html
au FileType python set expandtab


" Let abbreviations be in its own file
" ------------------------------------

if filereadable(expand("~/.vim/abbr"))
source ~/.vim/abbr
endif

"Delete trailing white space, useful for Python ;)
func! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
exe "normal `z"
endfunc
autocmd BufWrite *.py :call DeleteTrailingWS()

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Cope
" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" " Do :help cope if you are unsure what cope is. It's super useful!
map <leader>cc :botright cope<cr>
map <leader>n :cn<cr>
map <leader>p :cp<cr>

Change log

r96 by antoni.aloy on Apr 5, 2010   Diff
more python utils
Go to: 
Project members, sign in to write a code review

Older revisions

r95 by antoni.aloy on Apr 5, 2010   Diff
update with Tcomments and
tabcompletion
r94 by antoni.aloy on Apr 3, 2010   Diff
added json syntax
r93 by antoni.aloy on Apr 3, 2010   Diff
updated vimconfig to add textmate
pluggin
All revisions of this file

File info

Size: 9449 bytes, 300 lines
Powered by Google Project Hosting