File: scripts.vim

package info (click to toggle)
vim 5.6.070-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 9,424 kB
  • ctags: 9,182
  • sloc: ansic: 121,649; makefile: 1,225; awk: 683; sh: 530; perl: 359; csh: 6
file content (152 lines) | stat: -rw-r--r-- 4,087 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
" Vim support file to detect file types in scripts
"
" Maintainer:	Bram Moolenaar <Bram@vim.org>
" Last change:	2000 Jan 06

" This file is called by an autocommand for every file that has just been
" loaded into a buffer.  It checks if the type of file can be recognized by
" the file contents.  The autocommand is in $VIMRUNTIME/filetype.vim.


" Load the user defined scripts file first
" Only do this when the FileType autocommand has not been triggered yet
if !did_filetype() && exists("myscriptsfile") && file_readable(expand(myscriptsfile))
  execute "source " . myscriptsfile
endif

" Only do this when the FileType autocommand has not been triggered yet
if !did_filetype()

" Line continuation is used here, remove 'C' from 'cpoptions'
let scr_cpo_save = &cpo
set cpo-=C

" Bourne-like shell scripts: sh ksh bash
if getline(1) =~ '^#!.*[/\\][bk]\=a\=sh\>'
  if exists("is_bash")
    unlet is_bash
  endif
  if exists("is_kornshell")
    unlet is_kornshell
  endif
  " if bash is sh on your system as on Linux, you may prefer to
  " add the following in your .vimrc file:
  " let bash_is_sh=1
  if exists("bash_is_sh") || getline(1) =~ '^#!.*[/\\]bash\>'
    let is_bash=1
  elseif getline(1) =~ '^#!.*[/\\]ksh\>'
    let is_kornshell=1
  endif
  set ft=sh

" csh and tcsh scripts
elseif getline(1) =~ '^#!.*[/\\]t\=csh\>'
  set ft=csh

" Z shell scripts
elseif getline(1) =~ '^#!.*[/\\]zsh\>'
	\ || getline(1) =~ '^#compdef\>'
	\ || getline(1) =~ '^#autoload\>'
  set ft=zsh

" TCL scripts
elseif getline(1) =~ '^#!.*[/\\]\(tclsh\|wish\|expectk\|itclsh\|itkwish\)\>'
  set ft=tcl

" ELM Mail files
elseif getline(1) =~ '^From [a-zA-Z][a-zA-Z_0-9\.=-]*\(@[^ ]*\)\= .*[12][09]\d\d$'
  set ft=mail

" Expect scripts
elseif getline(1) =~ '^#!.*[/\\]expect\>'
  set ft=expect

" Gnuplot scripts
elseif getline(1) =~ '^#!.*[/\\]gnuplot\>'
  set ft=gnuplot

" Makefiles
elseif getline(1) =~ '^#!.*[/\\][^/\\]*make\>'
  set ft=make

" Perl
elseif getline(1) =~ '^#!.*[/\\][^/\\]*perl[^/\\]*\>'
  set ft=perl

" Python
elseif getline(1) =~ '^#!.*[/\\][^/\\]*python[^/\\]*\>'
  set ft=python

" sed
elseif getline(1) =~ '^#!.*sed\>'
  set ft=sed

" Vim scripts (must have '" vim' as the first line to trigger this)
elseif getline(1) =~ '^" *[vV]im$'
  set ft=vim

" Diff file:
" - "diff" in first line (context diff)
" - "Only in " in first line
" - "--- " in first line and "+++ " in second line (unified diff).
" - "*** " in first line and "--- " in second line (context diff).
" - "# It was generated by makepatch " in the second line (makepatch diff).
" - "Index: <filename>" in the first line (CVS file)
elseif getline(1) =~ '^diff\>' || getline(1) =~ '^Only in '
	\ || (getline(1) =~ '^--- ' && getline(2) =~ '^+++ ')
	\ || (getline(1) =~ '^\*\*\* ' && getline(2) =~ '^--- ')
	\ || getline(1) =~ '^\d\+\(,\d\+\)\=[cda]\d\+\>'
	\ || getline(2) =~ '^# It was generated by makepatch '
	\ || getline(1) =~ '^Index:\s\+\f\+$'
  set ft=diff

" PostScript Files (must have %!PS as the first line, like a2ps output)
elseif getline(1) =~ '^%![ \t]*PS'
  set ft=postscr

" Awk scripts
elseif getline(1) =~ '^#!.*awk\>'
  set ft=awk

" M4 scripts: Guess there is a line that starts with "dnl".
elseif getline(1) =~ '^\s*dnl\>'
	\ || getline(2) =~ '^\s*dnl\>'
	\ || getline(3) =~ '^\s*dnl\>'
	\ || getline(4) =~ '^\s*dnl\>'
	\ || getline(5) =~ '^\s*dnl\>'
  set ft=m4

" AmigaDos scripts
elseif $TERM == "amiga"
	\ && (getline(1) =~ "^;" || getline(1) =~ '^\.[bB][rR][aA]')
  set ft=amiga

" SiCAD scripts (must have procn or procd as the first line to trigger this)
elseif getline(1) =~ '^ *[pP][rR][oO][cC][nNdD] *$'
  set ft=sicad

" Purify log files start with "****  Purify"
elseif getline(1) =~ '^\*\*\*\*  Purify'
  set ft=purifylog

" XML
elseif getline(1) =~ '<?\s*xml.*?>'
  set ft=xml

" XXD output
elseif getline(1) =~ '^\x\{7}: \x\{4} \x\{4} '
  set ft=xxd

" RCS/CVS log output
elseif getline(1) =~ '^RCS file:' || getline(2) =~ '^RCS file:'
  set ft=rcslog

endif

" Restore 'cpoptions'
let &cpo = scr_cpo_save
unlet scr_cpo_save

endif " !did_filetype()

" vim: ts=8 tw=0 sts=0