![]() |
![]() |
NAIUA: OpenROAD SIG VIM Page |
![]() |
********************************** My settings inside _vimrc *************
set guifont=Lucida_Console:h9 set lines=55 set columns=88 set ic set nu set ts=4 set sw=4********************************** My w4gl.vim **********************
" Vim syntax file " Language: W4GL (Open Road) " Remove any old syntax stuff hanging around syn clear " Ignore case for all definitions below syn case ignore " The W4GL reserved words, defined as keywords. syn match w4glinclude "#include" syn match w4gldefine "#define" syn match w4gldefine "#undef" syn match w4glprecondit "#ifdef" syn match w4glprecondit "#ifndef" syn match w4glprecondit "#else" syn match w4glprecondit "#elseif" syn match w4glprecondit "#endif" syn match w4glmacro "$\<[a-z_][a-z0-9_]*\>" syn keyword w4glSpecial with default ifnull is null field byref true false syn keyword w4glFunction begin end syn keyword w4glFunction declare enddeclare syn keyword w4glFunction initialize method syn keyword w4glFunction on syn keyword w4glKeyword if then elseif else endif syn keyword w4glKeyword for to downto endfor syn keyword w4glKeyword while do endwhile syn keyword w4glKeyword exit return resume endloop continue syn keyword w4glKeyword call system callproc syn keyword w4glOperator not and or syn keyword w4glOperator in some all between exists like syn keyword w4glOperator any avg count distinct max min sum syn keyword w4glSqlStatement table alter create drop copy modify syn keyword w4glSqlStatement grant lock noaudit syn keyword w4glSqlStatement commit revoke rollback syn keyword w4glSqlStatement delete insert select update syn keyword w4glSqlStatement by having join group left order right union syn keyword w4glSqlStatement from into set values where repeated as syn keyword w4glType c char character text varchar long varchar syn keyword w4glType integer integer1 integer2 integer4 smallint syn keyword w4glType decimal float float4 float8 real syn keyword w4glType date money syn keyword w4glType array of syn keyword w4glType object_key table_key syn keyword w4glType security_label short security_label syn keyword w4glType byte byte varying long byte syn keyword w4glType procedure returning syn keyword w4glObjectType object fieldobject tablefield buttonfield textfield " Strings and characters: syn region w4glString start=+"+ skip=+\\\\\|\\"+ end=+"+ syn region w4glString start=+'+ skip=+\\\\\|\\"+ end=+'+ " Numbers: syn match w4glNumber "-\=\<\d*\.\=[0-9_]\>" " Comments: syn region w4glComment start="/\*" end="\*/" syn match w4glComment "--.*" syn sync ccomment w4glComment if !exists("did_w4gl_syntax_inits") let did_w4gl_syntax_inits = 1 " The default methods for highlighting. Can be overridden later. " hi link w4glSpecial Special " hi link w4glFunction Function " hi link w4glKeyword Keyword " hi link w4glOperator Operator " hi link w4glSqlStatement Statement " hi link w4glStatement Statement " hi link w4glString String " hi link w4glType Type " hi link w4glObjectType Type " hi link w4glNumber Number " hi link w4glComment Comment hi link w4glinclude Include hi link w4gldefine Define hi link w4glprecondit PreCondit hi link w4glmacro Define hi link w4glSpecial Special hi link w4glFunction Function hi link w4glKeyword Function hi link w4glOperator Operator hi link w4glSqlStatement Statement hi link w4glStatement Statement hi link w4glString String hi link w4glType Type hi link w4glObjectType Type hi link w4glNumber Number hi link w4glComment Comment endif let b:current_syntax = "w4gl" " vim: ts=8***************************************** My changes to syntax.vim **********
***** I Changed the colors to if &background == "dark" hi Comment term=bold ctermfg=Green guifg=#80a0ff hi Constant term=underline ctermfg=Magenta guifg=#ffa0a0 hi Special term=bold ctermfg=LightRed guifg=Orange hi Identifier term=underline cterm=bold ctermfg=Cyan guifg=#40ffff hi Statement term=bold ctermfg=Yellow guifg=#ffff60 gui=bold hi PreProc term=underline ctermfg=LightBlue guifg=#ff80ff hi Type term=underline ctermfg=LightGreen guifg=#60ff60 gui=bold else hi Comment term=bold ctermfg=DarkBlue guifg=DarkGreen hi Constant term=underline ctermfg=DarkRed guifg=DarkBlue hi Special term=bold ctermfg=DarkMagenta guifg=DarkBlue hi Identifier term=underline ctermfg=DarkCyan guifg=DarkBlue hi Statement term=bold ctermfg=Brown guifg=DarkBlue hi PreProc term=underline ctermfg=DarkMagenta guifg=Red hi Type term=underline ctermfg=DarkGreen guifg=DarkBlue endif ********* Code to add OR-syntax " OpenROAD au BufNewFile,BufRead *.e*,*.script so $VIM/syntax/w4gl.vim ********* Code for the syntax-menu 50amenu Syntax.KLMNO.OpenROAD :so $VIM/syntax/w4gl.vim
- Vim for OpenROAD.zip
VIM Enhancements by Paul Humphry:
1) Shortcut menus for methods, procedures & event blocks - click on a
method/procedure/event name & vim jumps to that section of code (see
attached gif)
2) Folding - text folds at BEGIN/END blocks - makes long files easier to
navigate
<F3> opens folds, <F4> closes. To turn off this feature, comment out the
line "set foldmethod=marker"
3) Help on keywords - place cursor on an openroad keyword then shift-K opens
the appropriate part of the openroad help file (need to use pre-MR help
file)
4) command completion - type part of a word, press CTRL-space & Vim will
guess the rest
Simply append the code below to your _vimrc file & enjoy! (or not, as the
case may be)
Paul Humphrey
Wellington Underwriting plc
" VIM goodies for openroad
" Tested on Vim 6.1 / Windows NT4 / OpenROAD 4.1 MR (using pre-MR help file)
" Paul Humphrey
" Wellington Underwriting plc
" 25/7/02
" NB Append these lines to your _vimrc
" Colours for fold indicators
hi folded guifg=black gui=bold
" Locate keyword in openroad help - doesn't work with 4.1 MR help file (no
4GL keywords)
map K ! winhlp32 -k<cword>
f:\apps32\devapps\or41\ingres\files\english\openroad.hlp<CR>
" find first occurrence in file of current word
map <F2> *:1<CR>n
" CTRL-SPACE: keyword completion
map <C-space> <C-n>
map! <C-space> <C-n>
map <C-S-space> <C-p>
map! <C-S-space> <C-p>
" Open folds
map <F3> zR
" Close Folds
map <F4> zM
" Build GOTO menu
map <F5> :$,$call CreateGoToMenu()<CR>
" Rebuild GoTo menus
map <F6> :call RebuildGoToMenus()<CR>
function! RebuildGoToMenus()
let l = line(".")
silent! aunmenu Methods
silent! aunmenu Procedures
silent! aunmenu Events
$,$call CreateGoToMenu()
exe ":".l
endfun
"create menu entries for OpenROAD Procedures, methods & event blocks
function! CreateGoToMenu()
let i = 1
let str = ""
let hasprocmenu = 0
let hasmethodmenu = 0
let haseventmenu = 0
let g:PH_mn = 10 " item number for current entry on main menu
let g:PH_property = "55."
let g:PH_more = ".&"
let g:PH_cnt = 1
while ( i <= a:lastline )
let str = getline(i)
if ( MatchAndAdd(i, str, "procedure", "Procedures") == 1 &&
hasprocmenu == 0 )
let hasprocmenu = 1
endif
if ( MatchAndAdd(i, str, "method", "Methods") == 1 && hasmethodmenu
== 0 )
let hasmethodmenu = 1
endif
if ( MatchAndAdd(i, str, "on ", "Events") == 1 && haseventmenu == 0
)
let haseventmenu = 1
endif
let i = i + 1
endwhile
if ( hasmethodmenu == 1 )
tearoff Methods
endif
if ( hasprocmenu == 1 )
tearoff Procedures
endif
if ( haseventmenu == 1 )
tearoff Events
endif
exe ":1"
endfun
function! MatchAndAdd(line, str, pat, title)
let pat = "^".a:pat
let menuflag = 0
let pos = match(a:str, pat)
let len = strlen(a:pat)
if ( pos == 0 )
let Name = escape(strpart(a:str, pos + len), " .")
if ( g:PH_mn > 300 )
let g:PH_property = g:PH_property . "320."
let g:PH_more = g:PH_more . "More---->.&"
let g:PH_mn = 10
endif
silent exe "an ".g:PH_property.g:PH_mn."
&".a:title.g:PH_more.g:PH_cnt ."-->".Name ":".a:line."<CR>"
let g:PH_mn = g:PH_mn + 10
let g:PH_cnt = g:PH_cnt + 1
let menuflag = 1
endif
" indicate whether we have created a menu entry
return menuflag
endfun
" Fold BEGIN/END blocks - this can be confused by CASE statements
set foldmethod=marker
set foldmarker=BEGIN,END;
" This will create the shortcut menus automatically when a file is opened
if has("autocmd")
augroup openroad
au!
autocmd BufReadPost,FileReadPost W*.e* :$,$call CreateGoToMenu()
augroup END
endif " has("autocmd")
![]() |
![]() |
Please send comments or corrections About these pages to