Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim filetype plugin file |
| 2 | " Language: Abaqus finite element input file (www.abaqus.com) |
| 3 | " Maintainer: Carl Osterwisch <osterwischc@asme.org> |
| 4 | " Last Change: 2004 May |
| 5 | |
| 6 | " Only do this when not done yet for this buffer |
| 7 | if exists("b:did_ftplugin") | finish | endif |
| 8 | |
| 9 | " Don't load another plugin for this buffer |
| 10 | let b:did_ftplugin = 1 |
| 11 | |
| 12 | " Save the compatibility options and temporarily switch to vim defaults |
| 13 | let s:cpo_save = &cpoptions |
| 14 | set cpoptions&vim |
| 15 | |
| 16 | " Folding |
| 17 | if version >= 600 |
| 18 | " Fold all lines that do not begin with * |
| 19 | setlocal foldexpr=getline(v:lnum)[0]!=\"\*\" |
| 20 | setlocal foldmethod=expr |
| 21 | endif |
| 22 | |
| 23 | " Set the format of the include file specification for Abaqus |
| 24 | " Used in :check gf ^wf [i and other commands |
| 25 | setlocal include=\\<\\cINPUT\\s*= |
| 26 | |
| 27 | " Remove characters up to the first = when evaluating filenames |
| 28 | setlocal includeexpr=substitute(v:fname,'.\\{-}=','','') |
| 29 | |
| 30 | " Define format of comment lines (see 'formatoptions' for uses) |
| 31 | setlocal comments=:** |
| 32 | setlocal commentstring=**%s |
| 33 | |
| 34 | " Definitions start with a * and assign a NAME, NSET, or ELSET |
| 35 | " Used in [d ^wd and other commands |
| 36 | setlocal define=^\\*\\a.*\\c\\(NAME\\\|NSET\\\|ELSET\\)\\s*= |
| 37 | |
| 38 | " Abaqus keywords and identifiers may include a - character |
| 39 | setlocal iskeyword+=- |
| 40 | |
| 41 | " Set the file browse filter (currently only supported under Win32 gui) |
| 42 | if has("gui_win32") && !exists("b:browsefilter") |
| 43 | let b:browsefilter = "Abaqus Input Files (*.inp *.inc)\t*.inp;*.inc\n" . |
| 44 | \ "Abaqus Results (*.dat)\t*.dat\n" . |
| 45 | \ "Abaqus Messages (*.pre *.msg *.sta)\t*.pre;*.msg;*.sta\n" . |
| 46 | \ "All Files (*.*)\t*.*\n" |
| 47 | endif |
| 48 | |
| 49 | " Define keys used to move [count] sections backward or forward. |
| 50 | " TODO: Make this do something intelligent in visual mode. |
| 51 | nnoremap <silent> <buffer> [[ :call <SID>Abaqus_Jump('?^\*\a?')<CR> |
| 52 | nnoremap <silent> <buffer> ]] :call <SID>Abaqus_Jump('/^\*\a/')<CR> |
| 53 | function! <SID>Abaqus_Jump(motion) range |
| 54 | let s:count = v:count1 |
| 55 | mark ' |
| 56 | while s:count > 0 |
| 57 | silent! execute a:motion |
| 58 | let s:count = s:count - 1 |
| 59 | endwhile |
| 60 | endfunction |
| 61 | |
| 62 | " Define key to toggle commenting of the current line or range |
| 63 | noremap <silent> <buffer> <m-c> :call <SID>Abaqus_ToggleComment()<CR>j |
| 64 | function! <SID>Abaqus_ToggleComment() range |
| 65 | if strpart(getline(a:firstline), 0, 2) == "**" |
| 66 | " Un-comment all lines in range |
| 67 | silent execute a:firstline . ',' . a:lastline . 's/^\*\*//' |
| 68 | else |
| 69 | " Comment all lines in range |
| 70 | silent execute a:firstline . ',' . a:lastline . 's/^/**/' |
| 71 | endif |
| 72 | endfunction |
| 73 | |
| 74 | " Restore saved compatibility options |
| 75 | let &cpoptions = s:cpo_save |