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

Auto​Wrap​Strings

by davidAlgis ALL New

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

Details

Installs

  • Total 0
  • Win 0
  • Mac 0
  • Linux 0
Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30 Mar 29 Mar 28 Mar 27 Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13 Mar 12 Mar 11 Mar 10 Mar 9 Mar 8 Mar 7 Mar 6 Mar 5 Mar 4 Mar 3 Mar 2 Mar 1 Feb 28
Windows 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 0 0 0 0 0
Mac 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 0 0 0 0 0
Linux 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 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.