Closed
Description
Consider the following code:
function functionWithLongName(numberOfWidgets,
numberOfWadgets) {
// ... code goes here ...
}
On hitting Enter after the {
, the cursor is placed not one shift-width in from the left, but one shift-width in from the start of the numberOfWadgets
line (i.e., the line on which the {
occurs). Any new line created within the function body (but not within another {
...}
block) gets the same treatment.
This is not actually specific to function definitions; the same happens with the following code.
while (functionWithLongName(variableWithLongName)
|| a < b) {
// ... body goes here ...
}
Of course this problem goes away if you use "Allman" rather than "1TBS" style and put the {
s on their own lines (because the {
s no longer occur on abnormally-indented lines), but it seems unfortunate for Vim to enforce that decision.
It seems like the "right" behaviour is something like:
- Find the line with the enclosing
{
- Combine it with as many previous lines as are needed to avoid an excess of closing delimiters
- Use the whitespace at the start of the resulting combined line as base for indentation
- Use that combined line for identifying control structures that need special treatment, like
switch
but maybe there's a better way.
Metadata
Metadata
Assignees
Labels
No labels