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 Jul 06
6 " Only do this when not done yet for this buffer
7 if exists("b:did_ftplugin") | finish | endif
9 " Don't load another plugin for this buffer
10 let b:did_ftplugin = 1
12 " Save the compatibility options and temporarily switch to vim defaults
13 let s:cpo_save = &cpoptions
18 " Fold all lines that do not begin with *
19 setlocal foldexpr=getline(v:lnum)[0]!=\"\*\"
20 setlocal foldmethod=expr
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*=
27 " Remove characters up to the first = when evaluating filenames
28 setlocal includeexpr=substitute(v:fname,'.\\{-}=','','')
30 " Remove comma from valid filename characters since it is used to
31 " separate keyword parameters
34 " Define format of comment lines (see 'formatoptions' for uses)
36 setlocal commentstring=**%s
38 " Definitions start with a * and assign a NAME, NSET, or ELSET
39 " Used in [d ^wd and other commands
40 setlocal define=^\\*\\a.*\\c\\(NAME\\\|NSET\\\|ELSET\\)\\s*=
42 " Abaqus keywords and identifiers may include a - character
45 " Set the file browse filter (currently only supported under Win32 gui)
46 if has("gui_win32") && !exists("b:browsefilter")
47 let b:browsefilter = "Abaqus Input Files (*.inp *.inc)\t*.inp;*.inc\n" .
48 \ "Abaqus Results (*.dat)\t*.dat\n" .
49 \ "Abaqus Messages (*.pre *.msg *.sta)\t*.pre;*.msg;*.sta\n" .
50 \ "All Files (*.*)\t*.*\n"
53 " Define keys used to move [count] sections backward or forward.
54 " TODO: Make this do something intelligent in visual mode.
55 nnoremap <silent> <buffer> [[ :call <SID>Abaqus_Jump('?^\*\a?')<CR>
56 nnoremap <silent> <buffer> ]] :call <SID>Abaqus_Jump('/^\*\a/')<CR>
57 function! <SID>Abaqus_Jump(motion) range
58 let s:count = v:count1
61 silent! execute a:motion
62 let s:count = s:count - 1
66 " Define key to toggle commenting of the current line or range
67 noremap <silent> <buffer> <m-c> :call <SID>Abaqus_ToggleComment()<CR>j
68 function! <SID>Abaqus_ToggleComment() range
69 if strpart(getline(a:firstline), 0, 2) == "**"
70 " Un-comment all lines in range
71 silent execute a:firstline . ',' . a:lastline . 's/^\*\*//'
73 " Comment all lines in range
74 silent execute a:firstline . ',' . a:lastline . 's/^/**/'
78 " Restore saved compatibility options
79 let &cpoptions = s:cpo_save