Syntax file 0.21-7 for Vim (12 October 2009)

A syntax file for Vim, wich covers (almost) all FreeBASIC 0.21b keywords.

TOC

  1. Download
  2. Description
  3. Installation
  4. Changelog
  5. TODOs
  6. How does it look?

Download

download freebasic.vim 0.21-7 (25 KB)

Description

Reading this description is not necessary if you only want to use the syntax file for any FreeBASIC dialect. You just need to install it.

There are now as of version 0.21-5 of this syntax file several options, which you can use to control which set of keywords you want to highlight. If you for example only want to work with the dialect "qb", there are many keywords which are not available or if they are, then often just with 2 leading underscores. So if you turn off the support for all other dialects, the script will show you if a keyword you want to use is available in "qb" by highlighting it (or not). The following options are available:

Option Standard Description
freebasic_lang_fb 1 Keywords available in the standard dialect "fb" will be highlighted
freebasic_lang_qb 1 All keywords which are available in the Q(uick)BASIC compatible dialect, will be highlighted
freebasic_lang_fblite 1 All keywords, which are available in #lang "fblite".
freebasic_lang_deprecated 1 Keywords available in the FreeBASIC 0.16 compativle mode
freebasic_crt 0 Various types, which are only available if working with include files from the directory 'crt' (i.e. SEEK_SET, EOF_, stdin, stdout)
freebasic_option_escape 0 If set to 1, escape sequences will be highlighted without having to put a '!' in front of the string. And they won't be highligted if the string begins with $"
freebasic_vbcompat 1 Functions only available when including vbcompat.bi (or file.bi for the file functions) will be highlighted
freebasic_operators 0 Highlight all non-text operators such as +, -, *, /, <, >, ...
Shortcuts (to be used directly in Vim)
freebasic_lang_all   Turn on highlighting of all FreeBASIC dialects.
freebasic_only_fb   Turn off highlighting for all dialects, except of lang "fb".
freebasic_only_qb   Turn off highlighting for all dialects, except of lang "qb".
freebasic_only_fblite   Turn off highlighting for all dialects, except of lang "fblite".
freebasic_only_deprecated   Turn off highlighting for all dialects, except of lang "deprecated".

All options must have the value 1 in order to be true. Any other value means false.

The values can be changed directly in the script. The section beginnnig at line 50 contains the switches which you can turn on (1) or off.

Or you use one of the shortcuts while in command mode: If you want to highlight only the keywords supported by #lang "qb" in the currently displayed file, use the following commands:

	:let freebasic_only_qb=1
	:syntax on

If you want to change the dialect using one of the other shortcuts during the same Vim session, you have to unlet the variable first:

	:unlet freebasic_only_qb
	:let freebasic_only_fb=1
	:syntax on

This will make vim highlight only keywords which are available with lang "fb". Keywords like gosub and call are now in the neutral color, because they can't be used with "fb".

The easiest way of course (but not always favored), is to leave support for all dialects active (which is the standard).

If there is another way to implement this functionality, maybe one that is easier to use, please tell me   :-)

INSTALL (LINUX):

This is only one way to do this! I'm not really aware of others  :-(

That's all   :-)

CHANGELOG

VersionChanges
0.21-7 (20091012)
  • freebasic_option_vbcompat added.
  • freebasic_option_operators added.
  • Highlighting of line numbers (as in 10 PRINT "Hello World"; for old-school programmers ;-)).
0.21-6 (20090815)
  • Some minor changes.
  • Added freebasic_option_escape which you can set to one, if you're using options escape in your code. This way, all escape sequences are highlighted by default. If you want to set this variable inside Vim, use the commands:
    :let freebasic_option_escape=1
    :syntax on
    If you want to turn it off again, use the same lines, but set it to 0 again, instead of 1. Of course you can make this behaviour default by setting this variable in the syntax file to 1.
0.21-5 (20090811)
  • The Script file can now be adjusted via variables so that only keywords supported by a particular dialect will be highlighted
  • Improvement of the RE's in preprocessor directives
  • The script can now differentiate between keywords which share the name but not the meaning. If you enter for example:
    dim as string foo
    then string will be recognized as type. If you, on the other hand, use
    ? string(4,"foo")
    it is highlighted as a function.
    Also, end by itself is a function, but if you use it as end sub it will become a statement
  • The $ extension used in string functions will now be highlighted
  • preserve will only be highlighted if used with redim
  • Block comments inside parenthesis haven't been displayed correctly
  • removed: explicit (not a stand-alone keyword)
  • moved: cast (statement)
  • moved: enum, type, (class*) (type)
  • moved: local (statement)
  • added: __FB_OPTION_GOSUB__ (intr. define)
  • added: QB: __wstring (type and function)
  • JavaDoc and Doxygen keywords removed again :(
0.21-4 (20090806)
  • removed: Block comment (/'...'/) defined twice
  • moved: data (statement)
  • moved: defined (preproc)
  • moved: lib (statement)
  • moved: local (statement)
  • moved: typeof (statement (?))
  • new: imageinfo (function; sice 0.20b)
  • new: option (statement; example: Declare Function ... as Double Option("sse"))
  • new: ? (alias for print; since the stone age :)
  • new: Highlighting of comments inside of #if directives (i.e.: #if /'blabla'/ defined(__FB_LINUX__))
0.21-3 (20090718)
  • Keywords: (enum ...) explicit (introduced 0.18.4), __screen (qb)
  • Defines: __FB_FPU__, __FB_FPMODE__
  • Meta command: $lang
  • Some minor bugs
  • New version number scheme: FBmajor(0).FBminor(21)-SyntaxFileVersion(3)
3.6 [0.21-2] (20090629)
  • many improvements (i hope)
  • better qb/deprecated support (i.e. keywords such as __cast; highligting of $meta commands)
  • DocBlock tags removed again, since Doxygen doesn't really support FreeBASIC. However, if you want highlighted tags, you can download the extended syntax file here.
  • keyword `class' added (classes aren't implemented yet, but the keyword is already reserved in lang "fb" and can't be used as a variable or function name in that dialect, therefore it's better to highlight it)
3.5 [0.21-1] (20090404)
  • new FB0.21 keywords added
  • changes in some regular expressions
3.4 (20081209)
  • some minor changes
3.3
  • did this version actually exist? ^^
3.2 (20080814)
  • new FB0.20 keywords
3.1 (20080415)
  • FB 18.4
3.0 (20080128)
  • Highlighting for DocBlocks added
2.0 (20070327)
  • FB 0.17
1.0 (2007?)
  • First version

TODOs

HOW DOES IT LOOK?

... depends on your color settings of course :) ...