Reputation: 1228
Is is possible to tweak VS Code so that when function gets autocompleted, it is written with ()
instead of just plain function name?
For example when I type str
and autocomplete to strlen
I would like to get strlen()
, it saves quite some time.
Upvotes: 68
Views: 49862
Reputation: 50195
There's currently no general setting that applies to all languages. VS Code leaves this to individual language services to implement (which is actually very reasonable given its extensibility model).
For JavaScript, use "javascript.suggest.completeFunctionCalls": true
. This will cause functions to be completed with their parameter signature.
Analogously, for TypeScript, use "typescript.suggest.completeFunctionCalls": true
.
For the PHP Intelephense extension, the default value of the intelephense.completion.triggerParameterHints
setting is true
.
For the Python extension, use "python.analysis.completeFunctionParens": true
.
For C and C++ using the vscode-cpptools extension, use "C_Cpp.autocompleteAddParentheses": true
.
For the Rust Analyzer extension, use rust-analyzer.completion.callable.snippets
setting with either the value "fill_arguments"
, or "add_parenthesis"
. "fill_arguments"
adds parenthesis and pre-fills arguments.
I did a cursory search through the Java extension's settings and didn't find anything that looked related (maybe I just missed it). I also tried googling for feature-request issue tickets ("github vscode java issues autocomplete function parenthesis
") and didn't find anything from a cursory look through the top search results.
For C#, see Method intellisense does not add parentheses #1453, which is closed to defer to the Roslyn issue IDE: Intellisense: Insert full method call #12363
The Dart extension just does this by default. See the dart.completeFunctionCalls
setting, described as: "Whether to insert parentheses and placeholders for positional and required arguments during code completions when using LSP. This feature is automatically disabled if commit characters are enabled.".
Loosely related: this (fairly outdated and closed) VS Code issue ticket: Autocomplete should insert parenthesis for methods #1021.
There are some extensions I'm not sure about their behaviour (and am too lazy to try out right now): R, Go, etc.
Upvotes: 2
Reputation: 21
In the new version of VS Code, there is no UI element we can check/uncheck to enable this feature for javascript or typescript but as another Stackoverflow solution suggests, you need to edit the settings.json file in your system and add the following lines to your JSON object
"typescript.suggest.completeFunctionCalls": true,
"javascript.suggest.completeFunctionCalls": true,
Originally posted at: VSCode autocomplete function *and method* parentheses (js/ts)
Upvotes: 2
Reputation: 18386
For Python when using the Python extension the relevant setting is:
python.autocomplete.addBrackets
As per the comment bellow, if you use Pylance the setting is:
python.analysis.completeFunctionParens
Upvotes: 29
Reputation: 9
In the latest release of vs code open setting > search "parenthesis" > scroll for
python>analysis: Complete Function Parens
mark tick Then you are ready to go.
Upvotes: 0
Reputation: 26256
For C and C++, use this setting:
"C_Cpp.autocompleteAddParentheses": true
Upvotes: 14
Reputation: 51
For Python, when using Pylance, add in settings.json:
"[python]": {
"python.analysis.completeFunctionParens": true,
},
Upvotes: 5
Reputation: 20891
It can be solved by ticking javascript.suggest.completeFunctionCalls
property up.
Upvotes: 78
Reputation: 332
You can go-to File->Preferences->Settings
Input python
And click on Edit in settings.json
After that write down "python.analysis.completeFunctionParens": true,
and reload VS Code
Upvotes: 4
Reputation: 111
Just like @snr's solution in JavaScript.
For TypeScript, you can try this:
"typescript.suggest.completeFunctionCalls": true
Upvotes: 11
Reputation: 414
in settings.json file
Set "python.autoComplete.addBrackets": true
.
Upvotes: 5
Reputation: 1
If you are working in flutter, try resetting all settings of VS Code because it do add parentheses by default.
Upvotes: 0
Reputation: 34138
Some language extensions allow using (
as a so-called "commit character" to trigger the insertion of a completion item. This works in at least TypeScript, JavaScript and Haxe.
If "editor.autoClosingBrackets"
has not been disabled, this will also auto-insert the closing )
.
If it doesn't work for a particular language extension, perhaps consider opening a feature request on the repository in question.
Upvotes: 8
Reputation: 1964
It's possible. You can create your own snippets, and it will be shown in the intellisense: User Defined snippets. You can also use snippet-creator extension for comfort.
Upvotes: 0