Skip to content

[feat][vfmt] Single-line short if expressions are incorrectly forced to multi-line #26915

@Jengro777

Description

@Jengro777

Describe the feature

When an if expression is short and fits comfortably on one line, v fmt still expands it into multiple lines:

// Input
if condition { 42 } else { 0 }

// Actual output after `v fmt`
if condition {
    42
} else {
    0
}

Use Case

// Before fmt (readable, compact)

status := if code == 200 { "OK" } else { "Error" }

// After fmt (verbose, less scannable)

status := if code == 200 {
    "OK"
} else {
    "Error"
}

Proposed Solution

No response

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Version used

V 0.5.1 99f141f

Environment details (OS name and version, etc.)

V full version V 0.5.1 1b3385c.99f141f
OS macos, macOS, 13.2.1, 22D68
Processor 8 cpus, 64bit, little endian, Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
Memory 0.31GB/8GB
V executable /Applications/v/v
V last modified time 2026-04-19 01:29:00
V home dir OK, value: /Applications/v
VMODULES OK, value: /Users/avey/.vmodules
VTMP OK, value: /tmp/v_501
Current working dir OK, value: /Users/avey/Documents/Dev/RuoQi/RuoQi-v/temp
env LDFLAGS "-L/usr/local/opt/openssl@3/lib"
Git version git version 2.50.0
V git status 0.5.1-1018-g99f141f7
.git/config present true
cc version Apple clang version 14.0.3 (clang-1403.0.22.14.1)
gcc version Apple clang version 14.0.3 (clang-1403.0.22.14.1)
clang version Apple clang version 14.0.3 (clang-1403.0.22.14.1)
tcc version tcc version 0.9.27 (x86_64 Darwin)
tcc git status thirdparty-macos-amd64 975f1ad8
emcc version N/A
glibc version N/A

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions