Automatically hard-wrap text
Published 2011-08-20 13:31 by martin, tagged as scripting, nu
There's a question if Vico can automatically hard-wrap text at a certain column. Vim can do this when the textwidth setting is non-zero.
This setting is not natively supported by Vico, so the natural follow up question was: "But can I script it?".
It turns out it can be scripted by listening to the "didModifyDocument" event, and inserting a newline when the line is too long, just like suggested:
Comments
at 2011-10-10 19:52 Anon said:
Is it possible to have this work in source code? Whatever Vico uses for standard indentation rules when I press enter seems fine to me. Also, I can't seem to get this to eval (even in a .txt file). Could you explain with more detail how to eval this stuff? (Or maybe have it in an auto-loaded .nu file)?
at 2011-10-11 06:08 martin said:
From the Vico menu, select Edit Site Script, paste it in and restart Vico.
If you want to enable this for all document types, remove the (((doc language) name) hasPrefix:"text.") condition. I think it would be annoying for source code though.
at 2011-10-30 20:08 jordow said:
Is there a way to get this script to respect indentation rules for source code?

at 2011-08-22 17:58 Ognen said:
Excellent! Thank you!