Since Zig doesn’t have multi-line comments, the most obvious way to me to comment out multiple container-level declarations and/or fields is to wrap them in a struct with an omitted name:
$ zig run main.zig
main.zig:1:7: error: duplicate struct member name '_'
const _ = struct {
^
main.zig:7:7: note: duplicate name here
const _ = struct {
^
main.zig:1:1: note: struct declared here
const _ = struct {
^~~~~
Could we fix the compiler and allow this? Of course I could give those structs some dummy names, like comment_var and comment_fn, but it obscures the intention, and also makes tools like zigimports report those identifiers as unused.
Or perhaps any other suggestions of quick ways of commenting out multiple lines in ‘spartan’ text editors? (like e.g. mousepad that I sometimes use).
It prevents the commented-out decl or field from being analyzed, in case it would generate a compile error. For decls it normally doesn’t matter because they are lazily analyzed, but fields are eagerly analyzed, so something like
(I would however second @Sze’s suggestion of using an editor that supports commenting/uncommenting multiple lines at once. Even without dedicated Zig language support, most modern editors let you duplicate the caret across multiple lines or use find/replace in a selected region to let you quickly insert or remove // from the beginning of lines.)