I am programming in Java, and whenever I type a { within a class Geany doesn't autocomplete for me since it assumes the ending brace to the brace I just typed is the ending brace for the class. Is there any way to disable this so that no matter what when I type a {, it will autocomplete to {}?
You can improve and configure behaviour of closing braces by using and configuring autoclose-plugin. Having this activated I getting the wished behaviour.
Related
I am getting annoyed by the autocompletion of the <> brackets in VSCode for Rust. While it might be useful when specifying generic types, it really bothers me when it autocompletes ">" for my smaller than operators.
I know I can disable autoclosing brackets completely, but is there a way to specify which of them should be considered brackets? I have installed the Rust extension, and without it, this is not a problem.
Angular brackets were added to autoClosingPairs in this pull request on the premise that Rust developers write generics more than comparison logic. This choice was re-discussed here tp no avail. It seems that there is no way to differentiate between generics and comparisons with vscode's current configuration options. However, there are two ways to remove this behaviour manually. One is to disable auto closing for all brackets by adding this line to your settings.json:
"editor.autoClosingBrackets": "never"
The other solution is to disable autoclosing for only angular brackets by removing the rust extension's configuration locally:
// .vscode/extensions/rust-lang.rust-x.x.x/language-configuration.json
"autoClosingPairs": [
{ "open": "<", "close": ">" },
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ remove this line
]
I have been using Ultraedit 16 for Perl editing.
I'm thinking about migrating to Notepad++ and gave it a try.
Here's how Ultraedit does highlighting. The cursor is on the last brace, and the matching first brace is highlighted:
Here's how Notepad++ highlights the same code. Cursor in the same place, but no highlight on the matching first brace.
I've looked through the configuration and searched elsewhere, it seems that the highlighting should be possible, but I'm not finding it.
Found it after more digging - Settings => Style Configurator => Global Styles => Brace Highlight style. I can set a background style there to make the matched brace more visible.
One possible result:
Creating a Netbeans code template for creating an slf logger is described here:
http://wiki.netbeans.org/SLF4JCodeTemplate
However creating code templates for log statements, e.g.
logger.debug("Something: {}", var);
is harder than expected because the template language doesn't balance curly braces. This means it will end the capture at the first ending curly brace.
There exist some examples, like for example How to get current class name in Netbeans code template? but they do not touch into the curly brace issue.
I have tried to escape them in every way I could think of so farm including:
${LOGGER default="logger" editable=false}.debug("${logMessage}${: '{}'}", ${EXP instanceof="<any>" default="exp"});
and
${LOGGER default="logger" editable=false}.debug("${logMessage}${: \{\}}", ${EXP instanceof="<any>" default="exp"});
but no luck. Also my google skills have been failing me so far.
Turns out there is a simple solution. I didn't find it anywhere near anything about netbeans code templates, but under a question about freemarker:
How to output ${expression} in Freemarker without it being interpreted?
Basically the answer is to use r"..." around the code, like this:
${LOGGER default="logger" editable=false}.debug("${logMessage}${:r"{}"}", ${EXP instanceof="<any>" default="exp"});
Now this can be assigned to sld, so I can type slt, expand it to:
logger.debug("logMessage: {}", <last variable>);
Where "logMessage" is selected (so I can overwrite it with something useful, one tab selects ": {}" so I can delete it if I want to log without parameters and a last tab selects which is the last assigned value (in case I want to replace or remove it).
Currently my eclipse formatter formats a multiline function call like this:
someObject.doSomething(
some().long().chain().of().methods()
);
But what I want is for eclipse to align the closing bracket with the method call:
someObject.doSomething(
some().long().chain().of().methods()
);
I have tried playing around with new line and wrapping rules in the code formatter but haven't been able to achieve this. What would be the solution?
After some time of digging I found a similar question which has an accepted answer but seems not to answer the same question:
Can the Eclipse formatter be configured to indent multiple lines between parenthesis properly?
The author of this question also states:
Edit: I found the settings for "Line Wrapping" -> "Default indentation
for wrapped lines" and "Default indentation for array initializes" and
have set them to "1" instead of "0". That is better for the array
initializers, but still doesn't indent closing parethesis to match the
opening parenthesis the way that I want it to:
The latest proposal on this does not take into account the closing );, but the first expression.
See Eclipse 4.23 (Q1 2022):
Method invocation wrapping indentation
It turns out it's not obvious how to indent a wrapped method invocation when the preceding expression itself is complex enough to also be wrapped into multiple lines.
Should the indentation be added to the existing indentation at the end of the expression, or just reset and assume that only the indentation of expression's first line matters?
Previously only the former behavior was available, now there's a setting to choose the latter.
The checkbox called Indent from the base expression's first line is located in the Line Wrapping > Wrapping settings > Function calls section, right under the Qualified invocations setting.
In the last time I often initialize arrays in this form :
int[] test = new int[]{1,2,3};
When I type '[', NetBeans immediately put the closing brace.
The question is - which is the macro to do the same job with curly braces ?
Select from menu Tools > Options, select Editor in toolbar, go for Code Completion tab.
You will see that Insert Closing Brackets Automatically is already automatically checked by default.
There was a guy, who asked an analogical question a while ago. There was no helpful answer. I guess that means that we should look for that in future versions.
I looked for solution too, for NetBeans 8.5 check answer, https://stackoverflow.com/a/38338967/7162006, in same window is option: Completition Selectors For Java add: {, autocomplete by hiting enter in editor. (classically)
This macro work to me:
Shortcut: Shift + {
Macro code: "}" caret-backward