Understanding python.analysis.autoSplitStrings in Pylance

June 23, 2026 · View on GitHub

Pylance is a fast and feature-rich language server extension for Python in Visual Studio Code, powered by the Pyright static type checker.

The python.analysis.autoSplitStrings setting controls whether Pylance automatically adds quotes and line-continuation characters when you split a string across multiple lines.

What is python.analysis.autoSplitStrings?

When enabled and you press Enter in the middle of a string literal, Pylance automatically closes the string on the current line and reopens it on the next line, keeping the literal valid. This produces correctly quoted, implicitly concatenated string fragments instead of a broken, unterminated string.

This exists because manually splitting a long string is error-prone — you have to add a closing quote, a continuation, and a reopening quote yourself. Automating it keeps long strings readable and syntactically correct.

Type: boolean Default: true Scope: window (applies to the whole VS Code window)

Example

Suppose your cursor (|) is inside a string and you press Enter:

message = "first part |second part"

With the setting enabled (the default), Pylance closes the string on the current line and reopens it on the next, keeping the literal valid:

message = "first part " \
    "second part"

With the setting disabled, pressing Enter leaves the string broken across two lines, producing an unterminated-string syntax error.

How to Change python.analysis.autoSplitStrings

Using the Settings UI

  1. Open the Command Palette (Ctrl+Shift+P / Cmd+Shift+P) and run Preferences: Open Settings (UI).
  2. Search for python.analysis.autoSplitStrings.
  3. Uncheck the box to disable it.

Using settings.json

{
    "python.analysis.autoSplitStrings": false
}

When to Use It

  • Keep enabled (the default) if you want long strings to stay valid automatically when you break them across lines.
  • Disable if you prefer to manage multi-line strings manually, for example when you rely on triple-quoted strings or specific formatting.

For more information on Pylance settings and customization, refer to the Pylance Settings and Customization documentation.


This document was generated with the assistance of AI and has been reviewed by humans for accuracy and completeness.