Sublime text auto semicolon

1

Is it possible to automatic add semicolon in sublime?

// 1
Route::get(|
// 2
Route::get(|);

After closing bracket insert ; at the end of line?

Sonique

Posted 2014-07-03T12:35:04.467

Reputation: 173

You'd have to delete that semicolon every time you type if (...) or for (...) or while (...) and such. – gronostaj – 2014-07-03T13:09:14.290

Answers

2

You can do that with the Auto Semi-Colon plugin. It does exactly what you ask for, and it works with version 2 and version 3 of Sublime Text.

Amr

Posted 2014-07-03T12:35:04.467

Reputation: 121

And it works very well too, taking action in function call syntax but not getting confused by a for(;;) construct. Typing a semicolon inside a string doesn't get interpreted specially though, which is fair enough, so binding a key sequence to a macro that goes to the end of line and inserts the semicolon would handle that case. – Nick – 2015-09-06T23:15:41.573

1

I seriously doubt that this useful. Text editor has no way of knowing where are you going to end the line. Closing bracket does not indicate the end of the line. I am not sure what language are you programming in. But in most languages that use (), there are multiple scenarios when you would continue the line after closing bracket. Consider following examples in C:

if(condition)
{
   statement;
}

also

variable = functionA() + functionB();

and finally

object.methodReturningObject().method();

As you can see, you will end up manually deleting semicolon in all these cases (and many more)

Art Gertner

Posted 2014-07-03T12:35:04.467

Reputation: 6 417