1" Vim filetype plugin file 2" Language: python 3" Maintainer: James Sully <[email protected]> 4" Previous Maintainer: Johannes Zellner <[email protected]> 5" Last Change: Tue, 06 September 2016 6" https://github.com/sullyj3/vim-ftplugin-python 7 8if exists("b:did_ftplugin") | finish | endif 9let b:did_ftplugin = 1 10let s:keepcpo= &cpo 11set cpo&vim 12 13setlocal cinkeys-=0# 14setlocal indentkeys-=0# 15setlocal include=^\\s*\\(from\\\|import\\) 16setlocal includeexpr=substitute(v:fname,'\\.','/','g') 17setlocal suffixesadd=.py 18setlocal comments=b:#,fb:- 19setlocal commentstring=#\ %s 20 21setlocal omnifunc=pythoncomplete#Complete 22 23set wildignore+=*.pyc 24 25let b:next_toplevel='\v%$\|^(class\|def)>' 26let b:prev_toplevel='\v^(class\|def)>' 27let b:next='\v%$\|^\s*(class\|def)>' 28let b:prev='\v^\s*(class\|def)>' 29 30execute "nnoremap <silent> <buffer> ]] :call <SID>Python_jump('n', '". b:next_toplevel."', 'W')<cr>" 31execute "nnoremap <silent> <buffer> [[ :call <SID>Python_jump('n', '". b:prev_toplevel."', 'Wb')<cr>" 32execute "nnoremap <silent> <buffer> ]m :call <SID>Python_jump('n', '". b:next."', 'W')<cr>" 33execute "nnoremap <silent> <buffer> [m :call <SID>Python_jump('n', '". b:prev."', 'Wb')<cr>" 34 35execute "onoremap <silent> <buffer> ]] :call <SID>Python_jump('o', '". b:next_toplevel."', 'W')<cr>" 36execute "onoremap <silent> <buffer> [[ :call <SID>Python_jump('o', '". b:prev_toplevel."', 'Wb')<cr>" 37execute "onoremap <silent> <buffer> ]m :call <SID>Python_jump('o', '". b:next."', 'W')<cr>" 38execute "onoremap <silent> <buffer> [m :call <SID>Python_jump('o', '". b:prev."', 'Wb')<cr>" 39 40execute "xnoremap <silent> <buffer> ]] :call <SID>Python_jump('x', '". b:next_toplevel."', 'W')<cr>" 41execute "xnoremap <silent> <buffer> [[ :call <SID>Python_jump('x', '". b:prev_toplevel."', 'Wb')<cr>" 42execute "xnoremap <silent> <buffer> ]m :call <SID>Python_jump('x', '". b:next."', 'W')<cr>" 43execute "xnoremap <silent> <buffer> [m :call <SID>Python_jump('x', '". b:prev."', 'Wb')<cr>" 44 45if !exists('*<SID>Python_jump') 46 fun! <SID>Python_jump(mode, motion, flags) range 47 if a:mode == 'x' 48 normal! gv 49 endif 50 51 normal! 0 52 53 let cnt = v:count1 54 mark ' 55 while cnt > 0 56 call search(a:motion, a:flags) 57 let cnt = cnt - 1 58 endwhile 59 60 normal! ^ 61 endfun 62endif 63 64if has("browsefilter") && !exists("b:browsefilter") 65 let b:browsefilter = "Python Files (*.py)\t*.py\n" . 66 \ "All Files (*.*)\t*.*\n" 67endif 68 69if !exists("g:python_recommended_style") || g:python_recommended_style != 0 70 " As suggested by PEP8. 71 setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8 72endif 73 74" First time: try finding "pydoc". 75if !exists('g:pydoc_executable') 76 if executable('pydoc') 77 let g:pydoc_executable = 1 78 else 79 let g:pydoc_executable = 0 80 endif 81endif 82" If "pydoc" was found use it for keywordprg. 83if g:pydoc_executable 84 setlocal keywordprg=pydoc 85endif 86 87let &cpo = s:keepcpo 88unlet s:keepcpo 89