Skip to content

Simple vim plugin to nicely wrap long strings

License

Notifications You must be signed in to change notification settings

GjjvdBurg/StringWrap.vim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StringWrap.vim

This is a very simple Vim plugin to wrap or unwrap long strings (mainly intended for Python). It will help you turn this:

a = (
    "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
)

into this (visually select the string or stand on the line and run :StringWrap):

a = (
    "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod "
    "tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim "
    "veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea "
    "commodo consequat. Duis aute irure dolor in reprehenderit in voluptate "
    "velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint "
    "occaecat cupidatat non proident, sunt in culpa qui officia deserunt "
    "mollit anim id est laborum."
)

and back again (using visual selection and :StringUnwrap). The maximum width is equal to your Vim textwidth setting. It will not work if the string is not on its own line.

Installation

Using Vundle:

Plugin 'gjjvdburg/StringWrap.vim'

Notes

For licensing information, see the LICENSE file.

To run the tests, use:

PYTHONPATH=./python/ python -m unittest test/test_string_wrap.py

Written by Gertjan van den Burg