Skip to content
Fix Code Error

How do I break a string in YAML over multiple lines?

March 13, 2021 by Code Error
Posted By: Anonymous

In YAML, I have a string that’s very long. I want to keep this within the 80-column (or so) view of my editor, so I’d like to break the string. What’s the syntax for this?

In other words, I have this:

Key: 'this is my very very very very very very long string'

and I’d like to have this (or something to this effect):

Key: 'this is my very very very ' +
     'long string'

I’d like to use quotes as above, so I don’t need to escape anything within the string.

Solution

Using yaml folded style. The indention in each line will be ignored. A line break will be inserted at the end.

Key: >
  This is a very long sentence
  that spans several lines in the YAML
  but which will be rendered as a string
  with only a single carriage return appended to the end.

http://symfony.com/doc/current/components/yaml/yaml_format.html

You can use the "block chomping indicator" to eliminate the trailing line break, as follows:

Key: >-
  This is a very long sentence
  that spans several lines in the YAML
  but which will be rendered as a string
  with NO carriage returns.

In either case, each line break is replaced by a space.

There are other control tools available as well (for controlling indentation for example).

See https://yaml-multiline.info/

Answered By: Anonymous

Related Articles

  • Use placeholders in yaml
  • insert tables in dataframe with years from 2000 to…
  • How to prevent scrolling the whole page?
  • Pandas pivot_table: filter on aggregate function
  • PHP parse/syntax errors; and how to solve them
  • SQL find sum of entries by date including previous date
  • YAML: Do I need quotes for strings in YAML?
  • binding backbone form view UIto model change to…
  • python 3.2 UnicodeEncodeError: 'charmap' codec can't…
  • What is your most productive shortcut with Vim?
  • Add calculated column to df2 for every row entry in…
  • I need to sum values with specific condition
  • Obtain most recent value for based on index in a…
  • How to unescape a Java string literal in Java?
  • What are the undocumented features and limitations…
  • data.table vs dplyr: can one do something well the…
  • How to resolve…
  • CKEditor setData not clearing or changing text in rte
  • Import Python Script Into Another?
  • Printing the most frequent value in a text
  • What is the difference between YAML and JSON?
  • Cannot make table responsive
  • 3 column layout HTML/CSS
  • Javascript and css animation
  • Difference between single and double quotes in Bash
  • VueJS and tinyMCE, custom directives
  • How to use 2 columns as "key" to get MAX value of…
  • GUI-based or Web-based JSON editor that works like…
  • jQuery.on() Delegation: Slightly complex selector…
  • Getting Monaco to work with Vuejs and electron
  • Moving average in MYSQL without dates but grouped by…
  • Error in styles_base.xml file - android app - No…
  • Oracle sql query to group two sets of dates if sequencials
  • How can I use/create dynamic template to compile…
  • Pandas / Python - Compare numerically each row with…
  • How can I fix MySQL error #1064?
  • Vim foldexpr matching pattern1 OR pattern2?
  • PyYaml: cannot access nested instance attributes…
  • Adding a guideline to the editor in Visual Studio
  • why my css code is not working in vuejs?
  • Removing double quotes from variables in batch file…
  • Smart way to truncate long strings
  • Polymer routing: inner routes not reflecting
  • Include YAML file in RMarkdown document
  • In Polymer 2.0 how to observe edits to properties of…
  • Collapse a vector of function calls in to one line,…
  • Python Monthly Change Calculation (Pandas)
  • Insert text with single quotes in PostgreSQL
  • What is the difference between single-quoted and…
  • Python - Modifying rows of a data frame where the…
  • Reset/remove CSS styles for element only
  • How to apply rolling t.test with pandas?
  • Is it possible to apply CSS to half of a character?
  • Escape a string in SQL Server so that it is safe to…
  • How to create a temporary table in SSIS control flow…
  • Google in-app billing, a toast breaks everything
  • When are you supposed to use escape instead of…
  • How to set width of mat-table column in angular?
  • Syntax error due to using a reserved word as a table…
  • Issues in parsing yaml file in golang
  • Nesting query results in BigQuery
  • Getting navigation duplicated error while the route…
  • Getting the closest string match
  • Vue routes doesn't work
  • Use vue-html-editor in vue-component
  • When trying to insert a table into a quill editor I…
  • Android adding simple animations while…
  • Playing HTML5 video on fullscreen in android webview
  • Polymer Behaviors sharing properties
  • Code conversion issue from Java to Kotlin
  • YAML equivalent of array of objects in JSON
  • Setting equal heights for div's with jQuery
  • Using Auto Layout in UITableView for dynamic cell…
  • How do I compare sequential characters in two…
  • SQL query return data from multiple tables
  • putting regex to make git diff split words at…
  • YAML Multi-Line Arrays
  • How get consecutives weeks in a group in df python?
  • Backbone.js - Should nested Views maintain…
  • Why is my code stuck in an infinite loop when scraping?
  • stylus style formatting in vue files with VSCode
  • VueJS: Bind div content to iframe src
  • How to detect escape key press with pure JS or jQuery?
  • How do I escape a string inside JavaScript code…
  • How to get the in HTML tables to fit content, and…
  • How can I set up an editor to work with Git on Windows?
  • How do SO_REUSEADDR and SO_REUSEPORT differ?
  • Backbone routing regex
  • regeneratorRuntime error using Monaco Editor with…
  • How can I parse a YAML file in Python
  • How to activate and or install plugins on CKEditor 5…
  • How to create a game over screen for a basic HTML/JS game?
  • How to insert a string which contains an "&"
  • how to scroll horizontal by button click like next…
  • How does PHP 'foreach' actually work?
  • Render problem in Android Studio arctic fox
  • Need Monaco Editor For Custom Expression
  • Can't get correct autoformat on save in Visual…
  • Dynamically inject shared styles in polymer element…
  • Active tab issue on page load HTML

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

Access denied for user ‘[email protected]’ (using password:NO)

Next Post:

XAMPP – MySQL shutdown unexpectedly

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error