I’m guessing you mean templates in JavaScript. You can
find the template in the toolbox at Samples/Abbreviations/JavaScript-common/*/keywords/if, edit it, and put in newlines to form the template to your preference.
No, not really. I’m talking more about the core language formatting. Think php or javascript or any c-style language. If I enter while (0) into the editor, then a left curly brace, it adds the right curly brace right after. End result is while (0) {} with the cursor between the curly braces.
Other IDEs … when enterint a language construct such as this, you’d type while ( and it would add the closing paren and then the curly braces based on a preferred style - the left on the same row or next and the right on the next or a few down with room for code. That’s a time saver that I miss from others and maybe I’ve missed something and komodo can do it…?
I write my code the same way as you do (curly braces on new line) and have not had any issues with this. To take your example, I would just wrote the following
while (0)
{
then this would auto complete to:
while (0)
{|}
Where “|” represents the cursor. Then when you press enter you get:
while (0)
{
|
}
Which pretty much covers your use-case. I’d be interested to hear exactly how you wish to perform these actions though.
Well I “am” one of the activestate folks, so consider this watched
I think it’s an interesting feature to have, but I like how our current implementation leaves this flexibility to the user.
Is it just curly braces that you want to do this for or are there other similar auto-completions that you’d like to see? If it’s just the curly braces then this could be easily implemented with a macro.
I could see a simple setting that provides 3 choices. 1 is to do it as is currently done. 2 would be formatting with braces on same line. 3 would be braces on separate lines. That would rock.
I don’t know that it really applies to anything else - not for my needs in php and javascript, anyway. Perhaps other languages have their construct where this would be useful, but I’m no expert on the others.
I’m not familiar with macros in komodo. My concern with macros would be… Do you have to do a different one for each language construct… if ( while ( for ( foreach ( do { switch ( etc. Know what I mean?
I love komodo, but it seems in supporting all languages, it’s lost some of the niceties that could be applied to each one, as is the case here. This might only apply to php and javascript or perl.
Keep in mind that what you may consider to be a nicety others may consider to be an annoyance. What you’re asking for would to me personally be a very annoying feature. That’s not to say it shouldn’t be offered as a feature, I’m just making an argument for why it’s not currently there.
I’ll cook up a simple macro as a prototype. If it works out well we can integrate it as a feature in the editor.
This will auto complete the second you write the left curly brace, provided there is nothing else to the right of the current caret position on the current line.
It’s not a very big snippet, most of what you see is boilerplate stuff.
Pretty sweet. Works like a charm. Good enough solution for me, I think. If it does it somewhere it shouldn’t, can always ctrl-z and back it out. Well done.
I will do that. Seems good for now, though I’ve only tested with fake code and at various levels of indentation.
FYI - I use the Allman style when doing C-style languages. The standard in komodo is old K&R, which is fine, but not for me. I suspect there are a lot who could go either way on this. http://en.wikipedia.org/wiki/Indent_style#BSD.2FAllman_style
I have the same issue. I can use auto-abbreviations to get the behavior I want, but I’d rather have a setting. Even more, though, I imagine these things are actually snippets somewhere? Maybe people could just edit them if we knew where to look…