0

Is there anyway to combine variable assignments in vim? For example, say I have:

let q1 = ""
let q2 = ""
let q3 = ""
let q4 = ""

Is there an alternative, such as:

let q1, q2, q3, q4 = "", "", "", ""

Or:

let q1=q2=q3=q4=""

etc.

1

There's :h :let-unpack, i.e.

let [foo, bar, baz] = [1, 2, 3]
| improve this answer | |
  • 1
    Help-topic: :h :let-unpack. – Ralf Jun 14 at 7:01
  • Also, given they should all share the same initial value, repeat() can be used. Even if we ignore this will lead to troubles with reference types, (list & dict), in all cases it's really ugly. – Luc Hermitte Jun 14 at 10:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.