Thanks Tim I really did not expect this to be such a hard problem. Might be the cases that it is easiest to just write a vimscript for this.
On Sat, May 19, 2012 at 9:17 PM, Tim Chase <[email protected]> wrote: > I hadn't seen a reply to this, so I thought I'd take a crack at it > > On 05/16/12 06:31, Fredrik Andersson wrote: >> I have a list of string values that I would like to autoformat but vim >> breaks the strings if there is a space inside of it. >> >> Can this be fixed somehow? >> >> example >> >> "sdasda", "asdasdasd", "afasfasf", "asdasda asdasd", "asdasd" >> >> becomes >> >> "sdasda", "asdasdasd", "afasfasf", "asdasda >> asdasd", "asdasd" >> >> but I want >> >> "sdasda", "asdasdasd", "afasfasf", >> "asdasda asdasd", "asdasd" > > While not automatic, you can use the following: > > %s/\%(^\%("[^"]*"\|[^"]\)*\)\@<=\%("[^"]*\|[^"]\+\)\%>50c/\r& > > (where "50" is where you want things to wrap; this could be > generated dynamically with an :exec and &tw to pull in the current > value of text-width) > > which should come fairly close. Unfortunately, you have to just > repeat its execution until it fails (rather than use the "/g" flag). > >> Extra bonus: It would be nice for it to support different string >> formatings (Python, ". ' and """) > > For single-vs-double quotes, I'd just hack together an alternate > version that swaps the desired character in. For the triple-quote > strings that Python allows, it becomes a whole other ball of wax. > > -tim > > > > > -- > You received this message from the "vim_use" maillist. > Do not top-post! Type your reply below the text you are replying to. > For more information, visit http://www.vim.org/maillist.php -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
