Home Download Buy Blog Forum Support

add parentheses to method names

add parentheses to method names

Postby pier on Tue Nov 06, 2012 6:39 pm

I imagine ST knows when a certain string is a method name. When I press cmd + R it lists all the methods in a file.

So... is it possible that when autocomplete throws a method name, after pressing tab, ST automatically adds parentheses after the method and move the cursor inside those parentheses?

Please excuse my ignorance if this already exists. I havent' been able to find any package or info about that.
pier
 
Posts: 92
Joined: Fri Jun 15, 2012 2:47 am

Re: add parentheses to method names

Postby pier on Wed Nov 07, 2012 8:54 pm

bump

Maybe I wasn't clear in my description...

If found string = function then add "()" and move cursor in between parentheses.

Is that possible?
pier
 
Posts: 92
Joined: Fri Jun 15, 2012 2:47 am

Re: add parentheses to method names

Postby GeniusIsme on Tue Nov 13, 2012 12:38 pm

Currently it is not possible to automatically check if autocomplete item is function using sublime api.
But there is some sublime plugins that perform syntax analisis. May be, you can tweak such a plugin to get desired behavior. But, i won't recommend this. In many (if not most) of languages one can use function in expression without calling it. And parentheses will not be welcome in that case.

If you have few functions, which you call frequently, snippets could help.
GeniusIsme
 
Posts: 5
Joined: Tue Nov 13, 2012 12:25 pm

Re: add parentheses to method names

Postby pier on Wed Nov 14, 2012 8:43 pm

That's a shame...

Creating snippets for methods in the current project is not as straightforward as I wanted... I wanted to use the all auto complete package but it doesn't work quite right either.

I will add a feature request to user Echo.
pier
 
Posts: 92
Joined: Fri Jun 15, 2012 2:47 am

Re: add parentheses to method names

Postby agibsonsw on Wed Nov 14, 2012 8:52 pm

As mentioned by the previous poster, we will not always want to add the brackets. Besides which, having accepted the completion-word, we only need to type an opening bracket.. So I hope that this feature is not added :D
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: add parentheses to method names

Postby pier on Sat Nov 17, 2012 2:50 am

agibsonsw wrote:As mentioned by the previous poster, we will not always want to add the brackets. Besides which, having accepted the completion-word, we only need to type an opening bracket.. So I hope that this feature is not added :D


The thing is that if this feature was implemented, it should go a step beyond and also generate an "automatic snippet" with all methods parameters so you wouldn't need to go and check the method definition. That way it should be pretty easy to erase all parameters if you wanted to use the method name as a reference, a parameter in another method, etc. Of course this should be customized in languages where you don't need parentheses, but you'd get the benefit of the automatic parameters too.

What you are suggesting is the way it's implemented now: you don't get auto complete with methods from other files, you have to manually go check the method definition, and write parentheses, parameters and commas.

I really don't see how having to manually go check the definition and writing everything is better. It's like going back to notepad IMHO.
pier
 
Posts: 92
Joined: Fri Jun 15, 2012 2:47 am


Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot], Proggie, Yahoo [Bot] and 27 guests