tags:

views:

168

answers:

6

I'm editing some file with extreamly long line in it. My current vim settings will wrap thoes long lines but breaking them at the same time. It's good to see that a very long line is wrapped but it's not very apeal to me that a very long line is broken to more than one line .So what I need is : let vim wrap a long line but without line breaking . I know all the magic is in .vimrc, so put the question in another way : which part of .vimrc I should change ?

============================================================================================== there are lots of complain that I don't put my question clearly . I agree and thank you for remind. Stolen from andrew comments , put my question in a more clear way : I'd like that the long lines are displayed over more than one terminal line; I don't like that vim inserts newlines into your actual text .

+3  A: 

Use

:set wrap

To wrap lines visually, i.e. the line is still one line of text, but Vim displays it on multiple lines.

Use

:set nowrap

To display long lines as just one line (i.e. you have to scroll horizontally to see the entire line).

Brian Rasmussen
When down voting, please leave a comment.
Brian Rasmussen
You're right. I downvoted because I understood the question was about newlines in the text, not displayed lines in the editor.
orip
+2  A: 

I'm not sure I understand completely, but you might be looking for the 'formatoptions' configuration setting. Try something like :set formatoptions-=t. The t option will insert line breaks to make text wrap at the width set by textwidth. You can also put this command in your .vimrc, just remove the colon (:).

Erik Hesselink
+4  A: 

Here's what you want:

" this enables "visual" wrapping
set wrap

" this turns off physical line wrapping (ie: automatic insertion of newlines)
set textwidth=0 wrapmargin=0
Laurence Gonsalves
A: 

Use :set nowrap .. works like a charm!

Vatsala
+1  A: 

:set tw=0

VIM won't auto-insert line breaks, but will keep line wrapping.

orip
+2  A: 

You may find set lbr useful; with set wrap on this will wrap but only cutting the line on whitespace and not in the middle of a word.

e.g.

without lbr the li
ne can be split on
a word

and

with lbr on the
line will be
split on 
whitespace only
Dave Tapley