Configure VIM for Genero BDL
The VIM editor
VIM is a well-known source code editor for programmers.
Automatic code completion, syntax highlighting and code formatting/indentation is supported by fglcomp and fglform compilers, when using VIM.
Configuring VIM for Genero BDL
Perform the following steps to enable code-completion for Genero in VIM:
- Locate the VIM resource file for your operating system user:
- On UNIX® platforms, the VIM resource file is ~/.vimrc.
- On Windows® platforms, the VIM resource file is %USERPROFILE%\_vimrc.
- Add the following lines to make VIM find Genero VIM files in
$FGLDIR/vimfiles:
let generofiles=expand($FGLDIR . "/vimfiles") if isdirectory(generofiles) let &rtp=generofiles.','.&rtp endif ...
- Add the next line to enable syntax highlighting in VIM:
syntax on
- Add the following lines to associate source file extensions to the corresponding syntax
definition
file:
au BufNewFile,BufRead *.per setlocal filetype=per au BufNewFile,BufRead *.4gl map <F2> mx:1,$!fglcomp --format -<CR>'x
- Disable case sensitivity for keywords by adding the following
line:
let fgl_ignore_case=1
Note: Genero BDL is not case sensitive and allows to use language keywords for identifiers (DEFINE name STRING
). Common style guidelines and the default VIM syntax highlighting encourage the use of uppercase keywords. This avoids highlighting of keywords used as identifiers. Case sensitive highlighting can be disabled by settingfgl_ignore_case
to 1 in the VIM resource file. When using this option, symbols like variable names matching language keywords (define name string
) will be highlighted. - To enable lowercase keywords in code completion proposals, add the following
line:
let fgl_lowercase_keywords=1
Note: Settingfgl_lowercase_keywords=1
implies implicitlyfgl_ignore_case=1
. - If you want to format/beautify the source code with
fglcomp --format
each time you save the file, add the following lines:" Formats the file whenever Vim writes it au BufWritePost *.4gl call FglWritePostHook() function! FglWritePostHook() silent! :!fglcomp --format --fo-inplace % if v:shell_error redraw! endif edit endfun
Note: The auto-formatting may not be done, if the source code contains errors. In this case the source file is left untouched, but it will be saved.
Using VIM on Microsoft Windows platforms
color shine
Using code completion with Genero and VIM
First make sure the Genero environment is set (FGLDIR, PATH).
Open a .4gl or .per file, start to edit the file with VIM.
When in insert mode, press CTRL-X
+ CTRL-O
, to get a list of
language elements to complete the instruction syntax or expression.
For convenience, TAB
can also be used to get the completion list as with the
CTRL-X
+ CTRL-O
key combinations. However, TAB
will only show the completion list, if the edit cursor is after a keyword. At the beginning of the
line, TAB
adds indentation characters.
Use the F2
function key to indent/beautify the current .4gl
source code, with the fglcomp --format beautifier tool.
For more details about VIM, see http://www.vim.org.