[lug] Wrapping lines of text in VIM

David Morris lists at morris-clan.net
Thu Sep 16 16:37:36 MDT 2004


On Thu, Sep 16, 2004 at 04:09:26PM -0600, Bill Thoen wrote:
> I have a text file that has fairly long lines and I'd to get them to wrap
> at about column 65. I'm using vi (vim, actually), and I set textwidth=0,
> wrapmargin=15 and wrap. With these settings, the new lines I add do wrap
> in the right place, but the existing ones don't unless I break each one
> manually.  Also these settings result in hard carriage returns.
> 
> Is there any way to set up vi so it wraps existing and new long lines at
> about column 65 and uses soft carriage returns? Or is asking vi to behave
> like a normal editor more than it can handle?

I am not clear from the above on what exactly it is you want
to do, but if I do understand correctly you are confused on
what the 'wrapmargin' option does.  Setting 'wrapmargin'
while 'textwidth' is 0 is just a way to have your linebreaks
set based on your terminal width rather than absolute column
number; 'wrapmargin' has nothing to do with the 'wrap'
option which changes how long lines are *displayed*, not how
they are broken into new lines when typing.

As far as I know, there is no way to set the 'wrap' option
to use a column less than the full screen width....but then
as you are only displaying a file differently rather than
changing where line breaks occur, I don't quit see any
benefit to doing that in the first place.

One option you might find useful is the 'linebreak' option
which will cause 'wrap' to break on a space rather than in
the middle of a word when it reaches the terminal width.

If I'm completely misunderstanding your question, please try
to clarify it a bit.

--David




More information about the LUG mailing list