1" Vim filetype plugin file 2" Language: Java 3" Maintainer: Dan Sharp <dwsharp at hotmail dot com> 4" Last Change: 2004 May 16 5" URL: http://mywebpage.netscape.com/sharppeople/vim/ftplugin 6 7if exists("b:did_ftplugin") | finish | endif 8let b:did_ftplugin = 1 9 10" Make sure the continuation lines below do not cause problems in 11" compatibility mode. 12let s:save_cpo = &cpo 13set cpo-=C 14 15" Go ahead and set this to get decent indenting even if the indent files 16" aren't being used. For people who really don't want any indentation, 17" let them turn it off. 18if !exists("g:ftplugin_java_no_indent") 19 setlocal cindent 20 21 "--------------------- 22 " Correctly indent anonymous classes 23 " From Johannes Zellner <[email protected]> 24 setlocal cinoptions+=j1 25 "--------------------- 26endif 27 28" For filename completion, prefer the .java extension over the .class 29" extension. 30set suffixes+=.class 31 32" Enable gf on import statements. Convert . in the package 33" name to / and append .java to the name, then search the path. 34setlocal includeexpr=substitute(v:fname,'\\.','/','g') 35setlocal suffixesadd=.java 36if exists("g:ftplugin_java_source_path") 37 let &l:path=g:ftplugin_java_source_path . ',' . &l:path 38endif 39 40" Set 'formatoptions' to break comment lines but not other lines, 41" and insert the comment leader when hitting <CR> or using "o". 42setlocal formatoptions-=t formatoptions+=croql 43 44" Set 'comments' to format dashed lists in comments. Behaves just like C. 45setlocal comments& comments^=sO:*\ -,mO:*\ \ ,exO:*/ 46 47setlocal commentstring=//%s 48 49" Change the :browse e filter to primarily show Java-related files. 50if has("gui_win32") 51 let b:browsefilter="Java Files (*.java)\t*.java\n" . 52 \ "Properties Files (*.prop*)\t*.prop*\n" . 53 \ "Manifest Files (*.mf)\t*.mf\n" . 54 \ "All Files (*.*)\t*.*\n" 55endif 56 57" Undo the stuff we changed. 58let b:undo_ftplugin = "setlocal cindent< cinoptions< suffixes< suffixesadd<" . 59 \ " formatoptions< comments< commentstring< path< includeexpr<" . 60 \ " | unlet! b:browsefilter" 61 62" Restore the saved compatibility options. 63let &cpo = s:save_cpo 64