Home Download Buy Blog Forum Support

Parentheses - expected behavior?

Parentheses - expected behavior?

Postby sam1am on Wed Mar 30, 2011 5:56 pm

Say I'm editing a document and I enter an opening bracket and hit enter. The closing bracket will show up automagically on the line below my cursor with proper indentation. If I do the same with an open parentheses, the closing parentheses will show up but at my cursor, not on the next line with proper indentation. Is this the expected behavior or is it a bug?

The pipe shows my cursor:
Code: Select all
myfunction() {
     |
}


Code: Select all
$foo = array(
     |)
sam1am
 
Posts: 6
Joined: Thu Feb 10, 2011 5:08 pm

Re: Parentheses - expected behavior?

Postby jps on Thu Mar 31, 2011 9:44 am

That's the expected behaviour, yeah.
jps
Site Admin
 
Posts: 3069
Joined: Wed Mar 19, 2008 12:33 pm

Re: Parentheses - expected behavior?

Postby skunkbad on Thu Oct 27, 2011 10:21 pm

It would be great if it would act more like a bracket. Is there a way that we can make the parenthesis act like a bracket?
skunkbad
 
Posts: 13
Joined: Wed Oct 26, 2011 5:30 pm

Re: Parentheses - expected behavior?

Postby spadgos on Tue Nov 01, 2011 10:55 pm

+1
spadgos
 
Posts: 121
Joined: Thu Oct 06, 2011 12:49 am

Re: Parentheses - expected behavior?

Postby stevetweeddale on Wed Mar 07, 2012 12:14 pm

Hey, this was annoying me, so I've hacked together this key binding to achieve this. It activates when you hit enter, if the preceding character is an opening parentheses.

Code: Select all
  // Treat (<enter>) like {<enter>}, indentation wise
  { "keys": ["enter"], "command": "insert_snippet", "args": {"contents": "\n\t$0\n"}, "context":
    [
      { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
      { "key": "setting.command_mode", "operand": false },
      { "key": "preceding_text", "operator": "regex_contains", "operand": "\\($", "match_all": true }
    ]
  }


I've not used it in anger yet, so might need tweaking, but it seems to be working.
stevetweeddale
 
Posts: 1
Joined: Wed Mar 07, 2012 12:10 pm


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot], trapgate, Yahoo [Bot] and 16 guests