View previous topic :: View next topic |
Author |
Message |
Carnildo Guru
Joined: 17 Jun 2004 Posts: 594
|
Posted: Wed Oct 17, 2007 8:07 pm Post subject: Disabling word-wrap in Vim |
|
|
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 |
|
|
absoluteflatness Tux's lil' helper
Joined: 21 Jan 2007 Posts: 138 Location: Blacksburg or Falls Church, VA
|
Posted: Wed Oct 17, 2007 10:15 pm Post subject: |
|
|
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 |
|
|
Carnildo Guru
Joined: 17 Jun 2004 Posts: 594
|
Posted: Wed Oct 17, 2007 11:03 pm Post subject: |
|
|
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 |
|
|
absoluteflatness Tux's lil' helper
Joined: 21 Jan 2007 Posts: 138 Location: Blacksburg or Falls Church, VA
|
Posted: Wed Oct 17, 2007 11:30 pm Post subject: |
|
|
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 |
|
|
Carnildo Guru
Joined: 17 Jun 2004 Posts: 594
|
Posted: Wed Oct 17, 2007 11:39 pm Post subject: |
|
|
Thanks. That seems to be acting the way I want it to. |
|
Back to top |
|
|
|