ivan
ivan

Reputation: 6322

Vimscript: Can list creation be split over multiple lines?

Does Vimscript allow for this notation style when creating a list?

let mylist = [
               "a",
               "b",
               "c"
             ]

Or is it confined to one-liners (let mylist = [ "a", "b", "c" ])? I'm writing a list that I can easily foresee adding elements to later.

Upvotes: 53

Views: 8627

Answers (1)

JaredPar
JaredPar

Reputation: 754893

You can make a statement in vimscript span multiple lines by adding a \ to the start of the next line

let mylist = [
  \"a",
  \"b",
  \"c",
  \]

This is covered in :help line-continuation (doc)

Upvotes: 67

Related Questions