Vanilla 1.1.1 is a product of Lussumo. More Information: Documentation, Community Support.
1 to 28 of 28
This is a feature that I am anxiously awaiting. It automatically inserts a matching bracket/character when it deems it appropriate. It’s designed in a pretty smart way in Textmate but it could possibly be improved upon further.
I’m going to just include a bunch of quotes from the Feature Request Compilation thread here.
Frederick: I want these two to be added to the list:
- Being able to double-click (selecting a word) and continue dragging (with the second click) to select more words.
- Automatic pairing of brackets (well, any character basically… plus the ability to specify those characters in a config file)...
martincohen: Ad Autopairing: I never saw this feature implement in a good way. It always does something I don’t want to. Providing another parser thread that will only balance paired characters is a big overhead, but this is planned for prototyping.
Frederick I would love it if you could elaborate on your little mini-rant there. I would have some suggestions for how this feature could work I guess, if I would just sit down and think about it. I think it could work in a pretty unobtrusive way if designed right…
Frederick: Autopairing of characters should behave just like TextMate, I think. Take a look at the manual for a description: http://macromates.com/textmate/manual/working_with_text#auto-paired_characters_quotes_etc
EJ12N: Do it how PHPEd just did it…
PHPed Website:
PHP Smart-Quotations and Brackets: If a user deletes a quote or bracket that was just entered, PhpED will optionally delete the closing quote or bracket that was just generated by the IDE. It will also override the generated quote or bracket if you type closing quote or bracket yourself.
Frederick: Yeah, that’s exactly the way Textmate does it too. I suggested that it be done the Textmate way… But I think it should also maybe sense if there’s an ending or starting bracket there already. Like if I have
);and type “(” at the beginning of the line, it shouldn’t become());it should simply be();and the same with an opening bracket…
It might become too complicated with more rules, or it might be just what is needed. You have to walk the line carefully, but I really like the feature even in its basic form. You can try it out live, on the web, in postEditor, a Javascript implementation (made with the mootools framework) that works like Textmate.
Now, I know Martin doesn’t like this feature. Please explain it in more detail, Martin. :)
I’d also like to direct some attention to this:
It’s there in SciTE, Editpad, jEdit and more, and I’m starting to miss it a little. It would be great if it was added.
Ok, here you are :)
martincohen: Ad Autopairing: I never saw this feature implement in a good way. It always does something I don’t want to. Providing another parser thread that will only balance paired characters is a big overhead, but this is planned for prototyping.
However, tell me which editor does it the way you like it. And why?
Hmm, yes, sorry, you already kind of answered me there. But… Couldn’t you elaborate on that? You mean that it inserts chars you don’t need? My experience has been that this doesn’t happen very often. And that it could probably be prevented by some extra rules, like what I suggested above. I should probably try and implement that with postEditor as base, and then try it out and see if I can find situations where it doesn’t do what one would assume the user wants. Could you give me some tips for different situations that I could try, some examples where it gets in your way rather than help you?
Textmate does it in a nice, pretty basic way and postEditor behaves the same I believe.
Anyone else think this might be good, or bad? Please express your thoughts, it’s awfully quiet in here.
I like this feature, helps a lot when coding =)
its very help ful, whyh not?
Mm, I prefer just the autoparing of braces. For parentheses, there are times when I add them into expressions after I coded the line, so if it autopairs at that time, I find it annoying. Perhaps we can just autopair parentheses if and only if there are no characters after the caret on the current line.
idyllrain: Mm, I prefer just the autoparing of braces. For parentheses, there are times when I add them into expressions after I coded the line, so if it autopairs at that time, I find it annoying. Perhaps we can just autopair parentheses if and only if there are no characters after the caret on the current line.
i aggree
I think it should sense if there’s a closing char right after the caret, maybe.
And it should be configurable which pairs it acts on.
I like this feature in general. As people have said, it has quite a few edge cases but I think that most of these can be accounted for.
I think the main problem is the difference between editing existing code, where you often don’t want autopairing as you’re adding a few chars here and there or correcting mistakes – and writing new code – where autopairing is really nice.
Taking into account a little bit of context around the cursor would seem to be the way to go, as suggested above.
I think like most people, I manually ‘autopair’ – I always type the opening a closing chars together and then move the cursor back 1 char to fill in the middle.
On the whole, I would like to see this feature in. It’s provided in gEdit by a plugin which works reasonably well, so that might be an option for intype?
Agreed… But I don’t think it should be a plugin. That’s what I vote for anyhow. Though you should be able to turn it off in the Preferences.
Also, when selecting text, pressing an opening char should surround the selection with the corresponding character pair.
But we should have some smartness for the caret context, yes. Maybe it’s best if one of the rules is that when there’s a word character (\w) to the right of the caret, it shouldn’t autopair. But when it’s EOL or whitespace, it’s fine. Hmm. Could you also keep track of which characters were automatically inserted? If you could do that it opens a few extra roads. For example, maybe it shouldn’t autoremove a closing brace that was there before, but one that was just inserted is okay? ... Hm, or maybe that’s unnecessary. It probably shouldn’t be all too complicated, to avoid confusion and performance degradation.
I think autopairing, if done, should be part of the language’s .itGrammar files. I don’t want to be in the middle of constructing a REGEX pattern and have it automatically insert a closing brace, bracket, or curly-brace because it’s trying to be “helpful”.
Basically, I think that if a feature exists, it shouldn’t be implemented within the main editor’s parser, but within the parser of the snippets and/or grammar file, this way it can be language/character (bracket, square-bracket, curly-brace, parenthesis, etc…) specific.
Personally, I’ve never used it, and I’m with Martin, I don’t particularly like it. I do like the underlining, highlighting, or embolding (or other method) of matching pairs…but that’s enough for me.
BrendonKoz: this way it can be language/character (bracket, square-bracket, curly-brace, parenthesis, etc…) specific.
So, what you’re suggesting is to be able to limit the feature to specific languages/scopes, and to specify on a scope-basis which characters are autopaired. I’m all for that.
Yes, exactly. Thank you for summarizing. I have problems doing that. ;)
Okay, you’re welcome :)
BrendonKoz: Yep, the feature is planned and we have it described as scoped, however it will be as a part of the “preferences” bundle item (that has not been yet introduced). The problem that I see in the implementation is with inserting unwanted brackets. Even such advanced software as Visual Assist is, has some troubles with guessing “to ) or not to )” :)
I believe that autopairing should be an option as suggested above. The best autopairig implementation I have seen so far is in Eclipse where the caret stays inside the pair and then with Tab you exit the paired block. Even if press enter it will keep the correct indentation. You can check it out.
On the other hand I am very much for brace/bracket/etc… matching. I am very much used to this feature, and especially when coding in languages such as Java where you need to find opening and closing pairs, it makes your eyes less sore.
Cheers,
Nick
Even if we can live without paired brackets and other paired characters, I think sometimes we miss them too much to just let them go…so because I’m not smart enough to come up with a better solution to this problem I came up with some small snippets to make our lives a little easier(they are for PHP, but they can be added to any bundle if modified accordingly):
empty_paired_single_quotes.itSnippet
{
title : "Empty Paired Single Quotes"
key_equivalent : 'Ctrl+'''
scope : 'source.php'
content : '''$1''$0'
}
empty_paired_double_quotes.itSnippet
{
title : "Empty Paired Double Quotes"
key_equivalent : 'Ctrl+Shift+'''
scope : 'source.php'
content : '"$1"$0'
}
empty_paired_parentheses.itSnippet
{
title : "Empty Paired Parentheses"
key_equivalent : 'Ctrl+9'
scope : 'source.php'
content : '($1)$0'
}
empty_paired_square_brackets.itSnippet
{
title : "Empty Paired Square Brackets"
key_equivalent : 'Ctrl+['
scope : 'source.php'
content : '[$1]$0'
}
empty_paired_curly_brackets.itSnippet
{
title : "Empty Paired Curly Brackets"
key_equivalent : 'Ctrl+Shift+['
scope : 'source.php'
content : '{$1}$0'
}
P.S. this actualy started with me being annoyed by what happens with the code highlighting when I have a single/double quote without it’s pair
P.P.S btw, hope this helps
The single/double quote highlighting problem was solved in another thread. :)
BrendonKoz: The single/double quote highlighting problem was solved in another thread. :)
I must have missed that, where was it?
http://intype.info/forums/discussion/252/code-highlighting-bug-with-escaped-quotes-021272/
:)
EDIT:
Whoops, that thread is similar, but links to the original which you can find here.
Here’s another post on it too…
http://intype.info/forums/discussion/273/declaring-a-double-quote-char-in-java/
@night_shift: I just figured it’d be handy for you to fix it, if you wanted. My second reply was more towards Frederick since he scans this forum about as often as I do, if not more. We both forget things we’ve already seen. ;)
Your added snippets are a completely different topic and could potentially be useful to someone else, so thanks for sharing!
BrendonKoz: We both forget things we’ve already seen. ;)
(_mock chides_) Thats what you get from not scanning the forum as much as you should! :P
@night_shift: My first reply was more towards Frederick and BrendonKoz since they scan this forum about as often as I do, if not more. They both forget things they’ve already seen. ;)
No offense to anyone! :P
BrendonKoz: Your added snippets are a completely different topic and could potentially be useful to someone else, so thanks for sharing!
Yep, what actually bugged me was that when I started typing a string (single/double quoted) everything after the first quote is highlighted as a string until I types the ending quote so I came up with … ZE SNIPPETZ!
1 to 28 of 28