Syntax file 0.21-7 for Vim (12 October 2009)
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:
||1||Keywords available in the standard dialect "fb" will be highlighted|
||1||All keywords which are available in the Q(uick)BASIC compatible dialect, will be highlighted|
||1||All keywords, which are available in #lang "fblite".|
||1||Keywords available in the FreeBASIC 0.16 compativle mode|
||0||Various types, which are only available if working with include files from the directory 'crt' (i.e. SEEK_SET, EOF_, stdin, stdout)|
||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
||1||Functions only available when including vbcompat.bi (or file.bi for the file functions) will be highlighted|
||0||Highlight all non-text operators such as +, -, *, /, <, >, ...|
|Shortcuts (to be used directly in Vim)|
||Turn on highlighting of all FreeBASIC dialects.|
||Turn off highlighting for all dialects, except of lang "fb".|
||Turn off highlighting for all dialects, except of lang "qb".|
||Turn off highlighting for all dialects, except of lang "fblite".|
||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
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
This is only one way to do this! I'm not really aware of others
- download the file
- (as root) copy the file
syntaxdirectory of your vim path (there should be already a freebasic syntax definition file in this path with the same name, but it is deprecated now).
# cp freebasic.vim /usr/share/vim/vim72/syntax(maybe your vim directory is somewhere else (i.e.
/usr/local/share/) and also check the version number (72)
- (as root) open the file
/usr/share/vim/vim72/filetype.vim(replace 72 with your version number, if needed) with a text editor (maybe vim? ) and search for the line
au BufNewFile,BufRead *.bas call s:FTVB("basic")and extend it to
au BufNewFile,BufRead *.bas,*.bi call s:FTVB("freebasic")
|3.6 [0.21-2] (20090629)|
|3.5 [0.21-1] (20090404)|
- Better regular expressions for floating point numbers
- Folding :'(
- Might contain errors as the script has undergone many changes since 0.21-4
- Some keywords are not in the correct category
- TBC ... ;)
HOW DOES IT LOOK?
... depends on your color settings of course :) ...