new line "\n" in yaml file

31,676

try this

test: |+
  This is a long string


  with new lines

| after the key helps in beginning of multiline text indented and maintain the indentation for the long string.

Share:
31,676
montrealmike
Author by

montrealmike

http://careers.stackoverflow.com/elfassy

Updated on July 09, 2022

Comments

  • montrealmike
    montrealmike almost 2 years

    I'd like to do this

    test: >
      This is a long string
      \n\n\n
      with new lines
    

    But it prints out the "\n" instead of making new lines.

    I know it's possible to do

    test: "This is a long string
          \n\n\n
          with new lines"
    

    But i'd rather not add quotes everywhere if possible. Thanks for the help!

    EDIT: I'd rather not use empty lines. In other words, i'd like to use \n to show empty lines to make my yml file more readable.

  • montrealmike
    montrealmike almost 12 years
    i'd like to use the \n notation instead of using empty lines (just for readability). Is there another way using the \n char?
  • abhas
    abhas almost 12 years
    then you have to use the qoutes...other solution i don't have any idea
  • abhas
    abhas almost 12 years