blob: d823d68c9bfc5663b3403b07f4fc3a2962872a63 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim filetype plugin file
2" Language: python
3" Maintainer: Johannes Zellner <johannes@zellner.org>
Bram Moolenaarb1332082013-10-06 14:22:40 +02004" Last Change: 2013 Sep 25
5" Last Change By Johannes: Wed, 21 Apr 2004 13:13:08 CEST
Bram Moolenaar071d4272004-06-13 20:20:40 +00006
7if exists("b:did_ftplugin") | finish | endif
8let b:did_ftplugin = 1
Bram Moolenaar9a7224b2012-04-30 15:56:52 +02009let s:keepcpo= &cpo
10set cpo&vim
Bram Moolenaar071d4272004-06-13 20:20:40 +000011
12setlocal cinkeys-=0#
13setlocal indentkeys-=0#
14setlocal include=\s*\\(from\\\|import\\)
15setlocal includeexpr=substitute(v:fname,'\\.','/','g')
16setlocal suffixesadd=.py
17setlocal comments-=:%
18setlocal commentstring=#%s
19
Bram Moolenaar18144c82006-04-12 21:52:12 +000020setlocal omnifunc=pythoncomplete#Complete
Bram Moolenaara40ceaf2006-01-13 22:35:40 +000021
Bram Moolenaar071d4272004-06-13 20:20:40 +000022set wildignore+=*.pyc
23
24nnoremap <silent> <buffer> ]] :call <SID>Python_jump('/^\(class\\|def\)')<cr>
25nnoremap <silent> <buffer> [[ :call <SID>Python_jump('?^\(class\\|def\)')<cr>
26nnoremap <silent> <buffer> ]m :call <SID>Python_jump('/^\s*\(class\\|def\)')<cr>
27nnoremap <silent> <buffer> [m :call <SID>Python_jump('?^\s*\(class\\|def\)')<cr>
28
29if exists('*<SID>Python_jump') | finish | endif
30
31fun! <SID>Python_jump(motion) range
32 let cnt = v:count1
33 let save = @/ " save last search pattern
34 mark '
35 while cnt > 0
36 silent! exe a:motion
37 let cnt = cnt - 1
38 endwhile
39 call histdel('/', -1)
40 let @/ = save " restore last search pattern
41endfun
42
43if has("gui_win32") && !exists("b:browsefilter")
44 let b:browsefilter = "Python Files (*.py)\t*.py\n" .
45 \ "All Files (*.*)\t*.*\n"
46endif
Bram Moolenaar9a7224b2012-04-30 15:56:52 +020047
Bram Moolenaarb1332082013-10-06 14:22:40 +020048" As suggested by PEP8.
49setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8
50
51" First time: try finding "pydoc".
52if !exists('g:pydoc_executable')
53 if executable('pydoc')
54 let g:pydoc_executable = 1
55 else
56 let g:pydoc_executable = 0
57 endif
58endif
59" If "pydoc" was found use it for keywordprg.
60if g:pydoc_executable
61 setlocal keywordprg=pydoc
62endif
63
Bram Moolenaar9a7224b2012-04-30 15:56:52 +020064let &cpo = s:keepcpo
65unlet s:keepcpo