blob: f63962f815408dc0cc265261b0876f019aca0943 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" 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
7if exists("b:did_ftplugin") | finish | endif
8
9" Don't load another plugin for this buffer
10let b:did_ftplugin = 1
11
12" Save the compatibility options and temporarily switch to vim defaults
13let s:cpo_save = &cpoptions
14set cpoptions&vim
15
16" Folding
17if version >= 600
18 " Fold all lines that do not begin with *
19 setlocal foldexpr=getline(v:lnum)[0]!=\"\*\"
20 setlocal foldmethod=expr
21endif
22
23" Set the format of the include file specification for Abaqus
24" Used in :check gf ^wf [i and other commands
25setlocal include=\\<\\cINPUT\\s*=
26
27" Remove characters up to the first = when evaluating filenames
28setlocal includeexpr=substitute(v:fname,'.\\{-}=','','')
29
30" Define format of comment lines (see 'formatoptions' for uses)
31setlocal comments=:**
32setlocal commentstring=**%s
33
34" Definitions start with a * and assign a NAME, NSET, or ELSET
35" Used in [d ^wd and other commands
36setlocal define=^\\*\\a.*\\c\\(NAME\\\|NSET\\\|ELSET\\)\\s*=
37
38" Abaqus keywords and identifiers may include a - character
39setlocal iskeyword+=-
40
41" Set the file browse filter (currently only supported under Win32 gui)
42if 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"
47endif
48
49" Define keys used to move [count] sections backward or forward.
50" TODO: Make this do something intelligent in visual mode.
51nnoremap <silent> <buffer> [[ :call <SID>Abaqus_Jump('?^\*\a?')<CR>
52nnoremap <silent> <buffer> ]] :call <SID>Abaqus_Jump('/^\*\a/')<CR>
53function! <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
60endfunction
61
62" Define key to toggle commenting of the current line or range
63noremap <silent> <buffer> <m-c> :call <SID>Abaqus_ToggleComment()<CR>j
64function! <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
72endfunction
73
74" Restore saved compatibility options
75let &cpoptions = s:cpo_save