Saturday, July 9, 2011

Setting "tw=0" - can text be wrapped at a custom length still?

Hi all,

This may or may not be a naive approach in Vim, so if there's a better way, please say.

Whenever I want to disable Vim wrapping lines at a certain width, I set this:

:set tw=0

And then my lines are never wrapped.

This is fine -- it's what I want.  But one thing I've always wondered about is if there's a way for Vim to still keep "tw=0" but soft-wrap at a certain length?  What I dislike about setting "tw=0" is that the size of the line is dependent on the size of my terminal.  What I'd like to achieve is still keeping "tw=0" set, but for vim to visual layout the lines as though it had wrapped at a width of, say, "78" characters, or some other value.

To give a reason why I even set "tw=0" in the first place, I often use vim to write long messages in HTML forms, especially textareas.  Often, these things don't like to have wrapped text at all, and I've found that if I set "tw=0" beforehand in Vim, I can then copy and paste the whole lot into a textarea, and when the text is submitted and displayed in something like a forum-post, it looks as though I had typed it directly into the textarea.

If the above is possible in still setting "tw=0" and visually making the lines appear to wrap, I would still want the behaviour of copying and pasting text  to still retain the fact that even though the lines appear to be wrapped at a certain value, they're still as one line.

I hope that makes sense, and I appreciate any suggestions people might have.  Note that I have read up on formatoptions and the like, and I thought some of those options might help; but I admit it was a guess on my part, and am unsure what side-effects setting them might have.  Was formatoptions the right thing to be reading about?  Any ":h" pointers are welcome as well.  :)

TIA!

Jason

--
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

No comments: