Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make Vim only do a soft word-wrap, not hard word-wrap

Tags:

vim

macvim

I've been using Vim for a week now. And I've noticed something.

I have textwidth unset, and I have wrap set. Now, my question is. Currently whenever I line longer than 120 characters (window width), it takes the last character, and just like that, wraps it. So if it's in the middle of a word it looks like this:

This is a very long sen|
tence, this looks very |
strange, don't you thin|
k?                     |

BTW, the | represents the text limit, very short in this case, to prove my point. So that says what my problem is, I would like a simply solution to this, as long as I don't lose any screen real estate.

Of course, the ideal solution would output the following, without modifying the text, only the output, the text remains in one line, but it appears to be spread over several:

This is a very long    |
sentence, this looks   |
very strange, don't you|
think?                 |

Thanks for any help you can provide. :)

Extra info:

  • OS: Mac OSX Mountain Lion
  • Using MacVim

I've tried the following:

set textwidth=120

set wrap
set linebreak

set fo=1
like image 803
greduan Avatar asked Nov 08 '12 17:11

greduan


People also ask

How do I turn off word wrap in Vim?

Command to toggle word wrap in Vim While :set wrap will turn on word wrap in Vim and :set nowrap will turn off word wrapping, you can also use both commands with the ! (bang) symbol to toggle word wrap.

How do you wrap text in Vim?

If you want to wrap lines in a specific area, move the cursor to the text you want to format and type gq followed by the range. For example, gqq wraps the current line and gqip wraps the current paragraph.

What is soft wrap text?

A soft return or soft wrap is the break resulting from line wrap or word wrap (whether automatic or manual), whereas a hard return or hard wrap is an intentional break, creating a new paragraph. With a hard return, paragraph-break formatting can (and should) be applied (either indenting or vertical whitespace).


1 Answers

set linebreak

is enough. It doesn't work when list is on, though.

like image 96
romainl Avatar answered Sep 28 '22 07:09

romainl