Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: Visual Basic |
| 3 | " Maintainer: Tim Chase <vb.vim@tim.thechases.com> |
| 4 | " Former Maintainer: Robert M. Cortopassi <cortopar@mindspring.com> |
| 5 | " (tried multiple times to contact, but email bounced) |
| 6 | " Last Change: 2004 May 25 |
| 7 | " 2004 May 30 Added a few keywords |
| 8 | |
| 9 | " This was thrown together after seeing numerous requests on the |
| 10 | " VIM and VIM-DEV mailing lists. It is by no means complete. |
| 11 | " Send comments, suggestions and requests to the maintainer. |
| 12 | |
| 13 | " For version 5.x: Clear all syntax items |
| 14 | " For version 6.x: Quit when a syntax file was already loaded |
| 15 | if version < 600 |
| 16 | syntax clear |
| 17 | elseif exists("b:current_syntax") |
| 18 | finish |
| 19 | endif |
| 20 | |
| 21 | " VB is case insensitive |
| 22 | syn case ignore |
| 23 | |
| 24 | syn keyword vbStatement Alias AppActivate As Base Beep Call Case |
| 25 | syn keyword vbStatement ChDir ChDrive Const Declare DefBool DefByte |
| 26 | syn keyword vbStatement DefCur DefDate DefDbl DefDec DefInt |
| 27 | syn keyword vbStatement DefLng DefObj DefSng DefStr Deftype |
| 28 | syn keyword vbStatement DefVar DeleteSetting Dim Do Each Else |
| 29 | syn keyword vbStatement ElseIf End Enum Erase Event Exit Explicit |
| 30 | syn keyword vbStatement FileCopy For ForEach Function Get GoSub |
| 31 | syn keyword vbStatement GoTo If Implements Kill Let Lib LineInput |
| 32 | syn keyword vbStatement Lock Loop LSet MkDir Name Next OnError On |
| 33 | syn keyword vbStatement Option Preserve Private Property Public Put |
| 34 | syn keyword vbStatement RaiseEvent Randomize ReDim Reset Resume |
| 35 | syn keyword vbStatement Return RmDir RSet SavePicture SaveSetting |
| 36 | syn keyword vbStatement SendKeys Select SetAttr Static Step Sub |
| 37 | syn keyword vbStatement Then Type Unlock Until Wend While Width |
| 38 | syn keyword vbStatement With Write |
| 39 | |
| 40 | syn keyword vbFunction Abs Array Asc AscB AscW Atn Avg CBool |
| 41 | syn keyword vbFunction CByte CCur CDate CDbl Cdec Choose Chr |
| 42 | syn keyword vbFunction ChrB ChrW CInt CLng Command Cos Count |
| 43 | syn keyword vbFunction CreateObject CSng CStr CurDir CVar |
| 44 | syn keyword vbFunction CVDate CVErr DateAdd DateDiff DatePart |
| 45 | syn keyword vbFunction DateSerial DateValue Day DDB Dir |
| 46 | syn keyword vbFunction DoEvents Environ EOF Error Exp FileAttr |
| 47 | syn keyword vbFunction FileDateTime FileLen Fix Format FreeFile |
| 48 | syn keyword vbFunction FV GetAllStrings GetAttr |
| 49 | syn keyword vbFunction GetAutoServerSettings GetObject |
| 50 | syn keyword vbFunction GetSetting Hex Hour IIf IMEStatus Input |
| 51 | syn keyword vbFunction InputB InputBox InStr InstB Int IPmt |
| 52 | syn keyword vbFunction IsArray IsDate IsEmpty IsError IsMissing |
| 53 | syn keyword vbFunction IsNull IsNumeric IsObject LBound LCase |
| 54 | syn keyword vbFunction Left LeftB Len LenB LoadPicture Loc LOF |
| 55 | syn keyword vbFunction Log LTrim Max Mid MidB Min Minute MIRR |
| 56 | syn keyword vbFunction Month MsgBox Now NPer NPV Oct Partition |
| 57 | syn keyword vbFunction Pmt PPmt PV QBColor Rate RGB Right |
| 58 | syn keyword vbFunction RightB Rnd RTrim Second Seek Sgn Shell |
| 59 | syn keyword vbFunction Sin SLN Space Spc Sqr StDev StDevP Str |
| 60 | syn keyword vbFunction StrComp StrConv String Switch Sum SYD |
| 61 | syn keyword vbFunction Tab Tan Time Timer TimeSerial TimeValue |
| 62 | syn keyword vbFunction Trim TypeName UBound UCase Val Var VarP |
| 63 | syn keyword vbFunction VarType Weekday Year |
| 64 | |
| 65 | syn keyword vbMethods Accept Activate Add AddCustom AddFile |
| 66 | syn keyword vbMethods AddFromFile AddFromTemplate AddItem |
| 67 | syn keyword vbMethods AddNew AddToAddInToolbar |
| 68 | syn keyword vbMethods AddToolboxProgID Append AppendChunk |
| 69 | syn keyword vbMethods Arrange Assert AsyncRead BatchUpdate |
| 70 | syn keyword vbMethods BeginTrans Bind Cancel CancelAsyncRead |
| 71 | syn keyword vbMethods CancelBatch CancelUpdate |
| 72 | syn keyword vbMethods CanPropertyChange CaptureImage CellText |
| 73 | syn keyword vbMethods CellValue Circle Clear ClearFields |
| 74 | syn keyword vbMethods ClearSel ClearSelCols Clone Close Cls |
| 75 | syn keyword vbMethods ColContaining ColumnSize CommitTrans |
| 76 | syn keyword vbMethods CompactDatabase Compose Connect Copy |
| 77 | syn keyword vbMethods CopyQueryDef CreateDatabase |
| 78 | syn keyword vbMethods CreateDragImage CreateEmbed CreateField |
| 79 | syn keyword vbMethods CreateGroup CreateIndex CreateLink |
| 80 | syn keyword vbMethods CreatePreparedStatement CreatePropery |
| 81 | syn keyword vbMethods CreateQuery CreateQueryDef |
| 82 | syn keyword vbMethods CreateRelation CreateTableDef CreateUser |
| 83 | syn keyword vbMethods CreateWorkspace Customize Delete |
| 84 | syn keyword vbMethods DeleteColumnLabels DeleteColumns |
| 85 | syn keyword vbMethods DeleteRowLabels DeleteRows DoVerb Drag |
| 86 | syn keyword vbMethods Draw Edit EditCopy EditPaste EndDoc |
| 87 | syn keyword vbMethods EnsureVisible EstablishConnection |
| 88 | syn keyword vbMethods Execute ExtractIcon Fetch FetchVerbs |
| 89 | syn keyword vbMethods Files FillCache Find FindFirst FindItem |
| 90 | syn keyword vbMethods FindLast FindNext FindPrevious Forward |
| 91 | syn keyword vbMethods GetBookmark GetChunk GetClipString |
| 92 | syn keyword vbMethods GetData GetFirstVisible GetFormat |
| 93 | syn keyword vbMethods GetHeader GetLineFromChar GetNumTicks |
| 94 | syn keyword vbMethods GetRows GetSelectedPart GetText |
| 95 | syn keyword vbMethods GetVisibleCount GoBack GoForward Hide |
| 96 | syn keyword vbMethods HitTest HoldFields Idle InitializeLabels |
| 97 | syn keyword vbMethods InsertColumnLabels InsertColumns |
| 98 | syn keyword vbMethods InsertObjDlg InsertRowLabels InsertRows |
| 99 | syn keyword vbMethods Item KillDoc Layout Line LinkExecute |
| 100 | syn keyword vbMethods LinkPoke LinkRequest LinkSend Listen |
| 101 | syn keyword vbMethods LoadFile LoadResData LoadResPicture |
| 102 | syn keyword vbMethods LoadResString LogEvent MakeCompileFile |
| 103 | syn keyword vbMethods MakeReplica MoreResults Move MoveData |
| 104 | syn keyword vbMethods MoveFirst MoveLast MoveNext MovePrevious |
| 105 | syn keyword vbMethods NavigateTo NewPage NewPassword |
| 106 | syn keyword vbMethods NextRecordset OLEDrag OnAddinsUpdate |
| 107 | syn keyword vbMethods OnConnection OnDisconnection |
| 108 | syn keyword vbMethods OnStartupComplete Open OpenConnection |
| 109 | syn keyword vbMethods OpenDatabase OpenQueryDef OpenRecordset |
| 110 | syn keyword vbMethods OpenResultset OpenURL Overlay |
| 111 | syn keyword vbMethods PaintPicture Paste PastSpecialDlg |
| 112 | syn keyword vbMethods PeekData Play Point PopulatePartial |
| 113 | syn keyword vbMethods PopupMenu Print PrintForm |
| 114 | syn keyword vbMethods PropertyChanged PSet Quit Raise |
| 115 | syn keyword vbMethods RandomDataFill RandomFillColumns |
| 116 | syn keyword vbMethods RandomFillRows rdoCreateEnvironment |
| 117 | syn keyword vbMethods rdoRegisterDataSource ReadFromFile |
| 118 | syn keyword vbMethods ReadProperty Rebind ReFill Refresh |
| 119 | syn keyword vbMethods RefreshLink RegisterDatabase Reload |
| 120 | syn keyword vbMethods Remove RemoveAddInFromToolbar RemoveItem |
| 121 | syn keyword vbMethods Render RepairDatabase Reply ReplyAll |
| 122 | syn keyword vbMethods Requery ResetCustom ResetCustomLabel |
| 123 | syn keyword vbMethods ResolveName RestoreToolbar Resync |
| 124 | syn keyword vbMethods Rollback RollbackTrans RowBookmark |
| 125 | syn keyword vbMethods RowContaining RowTop Save SaveAs |
| 126 | syn keyword vbMethods SaveFile SaveToFile SaveToolbar |
| 127 | syn keyword vbMethods SaveToOle1File Scale ScaleX ScaleY |
| 128 | syn keyword vbMethods Scroll SelectAll SelectPart SelPrint |
| 129 | syn keyword vbMethods Send SendData Set SetAutoServerSettings |
| 130 | syn keyword vbMethods SetData SetFocus SetOption SetSize |
| 131 | syn keyword vbMethods SetText SetViewport Show ShowColor |
| 132 | syn keyword vbMethods ShowFont ShowHelp ShowOpen ShowPrinter |
| 133 | syn keyword vbMethods ShowSave ShowWhatsThis SignOff SignOn |
| 134 | syn keyword vbMethods Size Span SplitContaining StartLabelEdit |
| 135 | syn keyword vbMethods StartLogging Stop Synchronize TextHeight |
| 136 | syn keyword vbMethods TextWidth ToDefaults TwipsToChartPart |
| 137 | syn keyword vbMethods TypeByChartType Update UpdateControls |
| 138 | syn keyword vbMethods UpdateRecord UpdateRow Upto |
| 139 | syn keyword vbMethods WhatsThisMode WriteProperty ZOrder |
| 140 | |
| 141 | syn keyword vbEvents AccessKeyPress AfterAddFile |
| 142 | syn keyword vbEvents AfterChangeFileName AfterCloseFile |
| 143 | syn keyword vbEvents AfterColEdit AfterColUpdate AfterDelete |
| 144 | syn keyword vbEvents AfterInsert AfterLabelEdit |
| 145 | syn keyword vbEvents AfterRemoveFile AfterUpdate |
| 146 | syn keyword vbEvents AfterWriteFile AmbienChanged |
| 147 | syn keyword vbEvents ApplyChanges Associate AsyncReadComplete |
| 148 | syn keyword vbEvents AxisActivated AxisLabelActivated |
| 149 | syn keyword vbEvents AxisLabelSelected AxisLabelUpdated |
| 150 | syn keyword vbEvents AxisSelected AxisTitleActivated |
| 151 | syn keyword vbEvents AxisTitleSelected AxisTitleUpdated |
| 152 | syn keyword vbEvents AxisUpdated BeforeClick BeforeColEdit |
| 153 | syn keyword vbEvents BeforeColUpdate BeforeConnect |
| 154 | syn keyword vbEvents BeforeDelete BeforeInsert |
| 155 | syn keyword vbEvents BeforeLabelEdit BeforeLoadFile |
| 156 | syn keyword vbEvents BeforeUpdate ButtonClick ButtonCompleted |
| 157 | syn keyword vbEvents ButtonGotFocus ButtonLostFocus Change |
| 158 | syn keyword vbEvents ChartActivated ChartSelected |
| 159 | syn keyword vbEvents ChartUpdated Click ColEdit Collapse |
| 160 | syn keyword vbEvents ColResize ColumnClick Compare |
| 161 | syn keyword vbEvents ConfigChageCancelled ConfigChanged |
| 162 | syn keyword vbEvents ConnectionRequest DataArrival |
| 163 | syn keyword vbEvents DataChanged DataUpdated DblClick |
| 164 | syn keyword vbEvents Deactivate DeviceArrival |
| 165 | syn keyword vbEvents DeviceOtherEvent DeviceQueryRemove |
| 166 | syn keyword vbEvents DeviceQueryRemoveFailed |
| 167 | syn keyword vbEvents DeviceRemoveComplete DeviceRemovePending |
| 168 | syn keyword vbEvents DevModeChange Disconnect DisplayChanged |
| 169 | syn keyword vbEvents Dissociate DoGetNewFileName Done |
| 170 | syn keyword vbEvents DonePainting DownClick DragDrop DragOver |
| 171 | syn keyword vbEvents DropDown EditProperty EnterCell |
| 172 | syn keyword vbEvents EnterFocus ExitFocus Expand |
| 173 | syn keyword vbEvents FootnoteActivated FootnoteSelected |
| 174 | syn keyword vbEvents FootnoteUpdated GotFocus HeadClick |
| 175 | syn keyword vbEvents InfoMessage Initialize IniProperties |
| 176 | syn keyword vbEvents ItemActivated ItemAdded ItemCheck |
| 177 | syn keyword vbEvents ItemClick ItemReloaded ItemRemoved |
| 178 | syn keyword vbEvents ItemRenamed ItemSeletected KeyDown |
| 179 | syn keyword vbEvents KeyPress KeyUp LeaveCell LegendActivated |
| 180 | syn keyword vbEvents LegendSelected LegendUpdated LinkClose |
| 181 | syn keyword vbEvents LinkError LinkNotify LinkOpen Load |
| 182 | syn keyword vbEvents LostFocus MouseDown MouseMove MouseUp |
| 183 | syn keyword vbEvents NodeClick ObjectMove OLECompleteDrag |
| 184 | syn keyword vbEvents OLEDragDrop OLEDragOver OLEGiveFeedback |
| 185 | syn keyword vbEvents OLESetData OLEStartDrag OnAddNew OnComm |
| 186 | syn keyword vbEvents Paint PanelClick PanelDblClick |
| 187 | syn keyword vbEvents PathChange PatternChange PlotActivated |
| 188 | syn keyword vbEvents PlotSelected PlotUpdated PointActivated |
| 189 | syn keyword vbEvents PointLabelActivated PointLabelSelected |
| 190 | syn keyword vbEvents PointLabelUpdated PointSelected |
| 191 | syn keyword vbEvents PointUpdated PowerQuerySuspend |
| 192 | syn keyword vbEvents PowerResume PowerStatusChanged |
| 193 | syn keyword vbEvents PowerSuspend QueryChangeConfig |
| 194 | syn keyword vbEvents QueryComplete QueryCompleted |
| 195 | syn keyword vbEvents QueryTimeout QueryUnload ReadProperties |
| 196 | syn keyword vbEvents Reposition RequestChangeFileName |
| 197 | syn keyword vbEvents RequestWriteFile Resize ResultsChanged |
| 198 | syn keyword vbEvents RowColChange RowCurrencyChange RowResize |
| 199 | syn keyword vbEvents RowStatusChanged SelChange |
| 200 | syn keyword vbEvents SelectionChanged SendComplete |
| 201 | syn keyword vbEvents SendProgress SeriesActivated |
| 202 | syn keyword vbEvents SeriesSelected SeriesUpdated |
| 203 | syn keyword vbEvents SettingChanged SplitChange StateChanged |
| 204 | syn keyword vbEvents StatusUpdate SysColorsChanged Terminate |
| 205 | syn keyword vbEvents TimeChanged TitleActivated TitleSelected |
| 206 | syn keyword vbEvents TitleActivated UnboundAddData |
| 207 | syn keyword vbEvents UnboundDeleteRow |
| 208 | syn keyword vbEvents UnboundGetRelativeBookmark |
| 209 | syn keyword vbEvents UnboundReadData UnboundWriteData Unload |
| 210 | syn keyword vbEvents UpClick Updated Validate ValidationError |
| 211 | syn keyword vbEvents WillAssociate WillChangeData |
| 212 | syn keyword vbEvents WillDissociate WillExecute |
| 213 | syn keyword vbEvents WillUpdateRows WriteProperties |
| 214 | |
| 215 | syn keyword vbTypes Boolean Byte Currency Date Decimal |
| 216 | syn keyword vbTypes Double Empty Integer Long Single String |
| 217 | |
| 218 | syn match vbOperator "[()+.,\-/*=&]" |
| 219 | syn match vbOperator "[<>]=\=" |
| 220 | syn match vbOperator "<>" |
| 221 | syn match vbOperator "\s\+_$" |
| 222 | syn keyword vbOperator And Or Not Xor Mod In Is Imp Eqv |
| 223 | syn keyword vbOperator To ByVal ByRef |
| 224 | syn keyword vbConst True False Null Nothing |
| 225 | |
| 226 | syn keyword vbTodo contained TODO |
| 227 | |
| 228 | "integer number, or floating point number without a dot. |
| 229 | syn match vbNumber "\<\d\+\>" |
| 230 | "floating point number, with dot |
| 231 | syn match vbNumber "\<\d\+\.\d*\>" |
| 232 | "floating point number, starting with a dot |
| 233 | syn match vbNumber "\.\d\+\>" |
| 234 | |
| 235 | " String and Character contstants |
| 236 | syn region vbString start=+"+ end=+"+ |
| 237 | syn region vbComment start="\<REM\>" end="$" contains=vbTodo |
| 238 | syn region vbComment start="'" end="$" contains=vbTodo |
| 239 | syn region vbLineNumber start="^\d" end="\s" |
| 240 | syn match vbTypeSpecifier "[a-zA-Z0-9][\$%&!#]"ms=s+1 |
| 241 | |
| 242 | " Define the default highlighting. |
| 243 | " For version 5.7 and earlier: only when not done already |
| 244 | " For version 5.8 and later: only when an item doesn't have highlighting yet |
| 245 | if version >= 508 || !exists("did_vb_syntax_inits") |
| 246 | if version < 508 |
| 247 | let did_vb_syntax_inits = 1 |
| 248 | command -nargs=+ HiLink hi link <args> |
| 249 | else |
| 250 | command -nargs=+ HiLink hi def link <args> |
| 251 | endif |
| 252 | |
| 253 | HiLink vbLineNumber Comment |
| 254 | HiLink vbNumber Number |
| 255 | HiLink vbConst Constant |
| 256 | HiLink vbError Error |
| 257 | HiLink vbStatement Statement |
| 258 | HiLink vbString String |
| 259 | HiLink vbComment Comment |
| 260 | HiLink vbTodo Todo |
| 261 | HiLink vbFunction Identifier |
| 262 | HiLink vbMethods PreProc |
| 263 | HiLink vbEvents Special |
| 264 | HiLink vbTypeSpecifier Type |
| 265 | HiLink vbTypes Type |
| 266 | HiLink vbOperator Operator |
| 267 | |
| 268 | delcommand HiLink |
| 269 | endif |
| 270 | |
| 271 | let b:current_syntax = "vb" |
| 272 | |
| 273 | " vim: ts=8 |