tojocky Messages: 607 Registered: April 2008 Location: UK
Contributor
The "text template" is very useful for programming.
By "Text template" I mean automatic replace or an user wizard completing code by writing a simple text and after then when I press "Enter" or "Space" key. for example: when I write "if" and after then when i presss "Enter" then need to automatic replace to:
if (<cursor>) {
}
This is a simple example... but in practice is very useful. Will be glad if this mechanism will be integrated in u++.
I post video records:
1. Text template editor
2. Use text templates in editor
amando1957 Messages: 57 Registered: November 2007 Location: Wien/Vienna/Viden
Member
Hi tojocky,
You are so right, I would appreciate that too. It would perform more than a simple macro recorder. I've seen a very good solution for in the editor of Code::Blocks. A simple key-value-list with the keyword-text-pairs will do.
for = for loop
ffor = double for loop
etc.
the coding there was:
- $ is the placeholder for user-entries queried later
(can be one or more), e.g. for var names.
- the | is where the caret will be put.
- tabs typed where shown (while the entry) as --->.
A usual key for inserting is "Ctrl + spacebar" or alike.
cas_ Messages: 20 Registered: July 2008 Location: Poland
Promising Member
Yes, except that Ctrl+space might not be a good choice, while it's already used for autocompletion. Some IDEs simply use the Tab key for this purpose (Resharper for example).
It's great to have the possibility to quickly jump through remaining placeholders. For example, if you had a for loop template like this:
for( $init$; $cond$; $inc$ ) {
$body$
}
then the first placeholder ($init$) would be selected by default and ready to be replaced by something useful. Then, after pressing some special key (maybe the same as used for macro expansion), cursor would jump to the next placeholder ($cond$), highlighting it and preparing for replacement.