May be someone is interested in getting the same.
I don't like syntax highlighting and extension specific template editing, but I like uniform template editing.
My solution is, adding..
regSet(115,`//enable uniform template editing for all files
Config(PG_E_TEMPLAT,1,LOCAL)
Config(PG_E_SYNTAX,0)
Config_String(VTM_Name,"general.vtm",LOCAL)
`)
..to startup.vdm, and adding file general.vdm to the Vedit installation directory. The example 'general.vdm' does automatically indent/undent on '{'/'}'.
Unfortunately the template macro is not called after [RETURN], so the indent function can not be done before the first character is entered into the line following the "{".
?? Is there some method to directly react on [RETURN]?
The example 'general.vtm' is listed below.
Regards
Bernd
---------------------------------
//
// general.vtm - general template-editing macro.
//
// Due to
// regSet(115,`//enable uniform template editing for all files
// Config(PG_E_TEMPLAT,1,LOCAL)
// Config(PG_E_SYNTAX,0)
// Config_String(VTM_Name,"general.vtm",LOCAL)
// `)
// .. in startup.vdm, this macro will be activated for each opened file.
//
// Function:
// - indent current line, if
// ("{" is at the end of the previous line) and
// (the indentation level of the current line is the same as that of the previous line)
// and (a non-white character is entered at that indentation level)
// - undent current line, if
// ("}" is eneterd at the indentation level of the current line)
//
#107 = curPos
if (!atBof & curChar(-1) == 125) { // 125 is '}'
// check for undent current line
char(-1)
if (curCol > 1 & searchBlock('|!|B', bolPos, curPos, BEGIN+NOERR) == 0 ) {
doVisual('\ME\EFU')
char
} else {
gotoPos(#107)
}
return;
}
// check for indentation of current line
#108 = curCol-1
gotoPos(bolPos)
if (curPos != #107 & curPos >= 1+newlineChars) {
char(-newlineChars)
if (curChar(-1) == 123 & match('|N') == 0) { // 123 is '{'
gotoPos(bolPos)
match ('|B', ALL+ADVANCE)
if (curCol == #108) {
line(1)
match ('|B', ALL+ADVANCE)
if (curCol == #108) {
doVisual('\ME\EFI')
char
return
}
}
}
}
gotoPos(#107)
return
|
|