Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Disabling word-wrap in Vim
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Carnildo
Guru
Guru


Joined: 17 Jun 2004
Posts: 594

PostPosted: Wed Oct 17, 2007 8:07 pm    Post subject: Disabling word-wrap in Vim Reply with quote

When editing a .txt file in Vim, it will hard-wrap lines somewhere around 80 characters. If the line begins with a funny character, it then inserts the character at the beginning of the wrapped text. This is extremely annoying. Is there some way of disabling it (both the hard-wrapping and the auto-character-insertion), or do I need to stop giving files ".txt" extension?
Back to top
View user's profile Send private message
absoluteflatness
Tux's lil' helper
Tux's lil' helper


Joined: 21 Jan 2007
Posts: 138
Location: Blacksburg or Falls Church, VA

PostPosted: Wed Oct 17, 2007 10:15 pm    Post subject: Reply with quote

To disable hard-wrapping, you can say ":set nowrap" in vim. This completely disables wrapping of any kind: long lines will simply scroll off to the right. To disable word-wrap, you can use ":set nolbr". This preserves vim's wrapping on characters, but not on words. Either of these can be put in your .vimrc file (without the leading colon) to set them by default.
Back to top
View user's profile Send private message
Carnildo
Guru
Guru


Joined: 17 Jun 2004
Posts: 594

PostPosted: Wed Oct 17, 2007 11:03 pm    Post subject: Reply with quote

Neither of those works, and neither sounds like what I want.

What I want is for Vim to treat text the same way it treats source code: display it wrapped at word boundaries when the text would otherwise run off the edge of the terminal, but without actually inserting newline characters or any other garbage.
Back to top
View user's profile Send private message
absoluteflatness
Tux's lil' helper
Tux's lil' helper


Joined: 21 Jan 2007
Posts: 138
Location: Blacksburg or Falls Church, VA

PostPosted: Wed Oct 17, 2007 11:30 pm    Post subject: Reply with quote

So, it sort of sounds like you want ":set formatoptions=l" (that's an L), and then ":set lbr". This should make vim visually wrap at word boundaries, and the formatoptions part stops vim from inserting newlines.

I think that's what you said you wanted, but my reading comprehension's at low tide at the moment.
Back to top
View user's profile Send private message
Carnildo
Guru
Guru


Joined: 17 Jun 2004
Posts: 594

PostPosted: Wed Oct 17, 2007 11:39 pm    Post subject: Reply with quote

Thanks. That seems to be acting the way I want it to.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum