ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Auto​Wrap​Strings

by davidAlgis ALL

A sublime text package to split long string on save on python

Details

Installs

  • Total 41
  • Win 27
  • Mac 8
  • Linux 6
Dec 24 Dec 23 Dec 22 Dec 21 Dec 20 Dec 19 Dec 18 Dec 17 Dec 16 Dec 15 Dec 14 Dec 13 Dec 12 Dec 11 Dec 10 Dec 9 Dec 8 Dec 7 Dec 6 Dec 5 Dec 4 Dec 3 Dec 2 Dec 1 Nov 30 Nov 29 Nov 28 Nov 27 Nov 26 Nov 25 Nov 24 Nov 23 Nov 22 Nov 21 Nov 20 Nov 19 Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9
Windows 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1
Mac 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

AutoWrapStrings

AutoWrapStrings is a Sublime Text package that automatically wraps long Python string literals to fit within a specified maximum line length. The plugin processes both single/double-quoted strings and triple‑quoted strings, adjusting the content to avoid exceeding the defined column width.

[!WARNING]
While AutoWrapStrings aims to reformat Python string literals accurately, it may contain edge cases where the wrapping does not behave as expected. Use with caution and consider reviewing changes after applying auto wrap.

Installation

You only need to place the packages files in a folder named AutoWrapStrings in your Sublime Text Packages directory.

Usage

  • Manual Wrapping:
    Open the Command Palette (via Ctrl+Shift+P or Cmd+Shift+P on macOS) and run the command AutoWrap: Apply Auto Wrap to File to manually trigger auto wrapping.

  • Auto-Wrap on Save:
    When you save a Python file, if the setting apply_on_save is enabled (default is disabled), the plugin will automatically reformat string literals to ensure no line exceeds the max-line-length (default is 79).

  • Configurable Settings:
    Customize the maximum line length and enable or disable auto-wrapping on save through the settings available in Preferences/Package Settings\AutoWrapStrings\Settings.

Note

AutoWrapStrings has been made completely for Python script.

For a more general plugin that wrapped lines you can use Wrap Plus. It might works better for general purposes, but in a python context AutoWrapStrings might be more appropriate, for example:

long_f_string = f" mollis. Suscipit nisl suspendisse senectus at laoreet efficitur per consectetur. Posuere potenti sollicitudin metus dictum dictum neque magnis. Accumsan, {long_string}! "

is wrapped like this with WrapPlus:

long_f_string = f" mollis. Suscipit nisl suspendisse senectus at laoreet
    efficitur per consectetur. Posuere potenti sollicitudin metus dictum
    dictum neque magnis. Accumsan, {long_string}! "

Which break the python code. While AutoWrapStrings does it like that:

long_f_string = f" mollis. Suscipit nisl suspendisse senectus at laoreet"
    f"efficitur per consectetur. Posuere potenti sollicitudin metus dictum"
    f"dictum neque magnis. Accumsan, {long_string}!"

Trying to not break the code.