9

Is there a way to split a one-line instruction into several lines?

For example, I'd like to transform

setlocal variable_name = condition1 ? "1" : condition2 ? "0" : condition3 ? "a long string" : "another long string" 

into

setlocal variable_name = condition1 ? "1" : 
                         condition2 ? "0" : 
                         condition3 ? "a long string" : 
                                      "another long string" 

but when I try it like above, it raises "Invalid argument" error.

10

To have multiple lines in a vimscript you need to prepend the next lines with \

setlocal variable_name = condition1 ? "1" : 
                       \ condition2 ? "0" : 
                       \ condition3 ? "a long string" : 
                       \              "another long string" 

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.