Wikia

Vim Tips Wiki

Changes: 80 character line wrap without broken words

Edit

Back to page

(Change <tt> to <code>, perhaps also minor tweak.)
(Comments)
Line 36: Line 36:
 
:<code>w</code> Trailing white space indicates a paragraph continues in the next line. A line that ends in a non-white character ends a paragraph.
 
:<code>w</code> Trailing white space indicates a paragraph continues in the next line. A line that ends in a non-white character ends a paragraph.
 
I'm not familiar with the <code>w</code> option and am not sure if it is doing anything useful in this tip. I guess this tip should be merged to one of those above. [[User:JohnBeckett|JohnBeckett]] 03:09, May 16, 2012 (UTC)
 
I'm not familiar with the <code>w</code> option and am not sure if it is doing anything useful in this tip. I guess this tip should be merged to one of those above. [[User:JohnBeckett|JohnBeckett]] 03:09, May 16, 2012 (UTC)
  +
  +
::I think what's useful about this tip is that it explains how to hard-wrap text that's already entered. The "wrap" option only will work on text as it's entered, if I remember correctly. I'm often editing HTML with extremely long lines, so I use this fairly often.[[User:Gay Karate Man|Gay Karate Man]] ([[User talk:Gay Karate Man|talk]]) 21:09, October 10, 2012 (UTC)

Revision as of 21:09, October 10, 2012

Recently created tip

We have not yet decided whether to keep this tip as its own page or merge it somewhere else. If you have a suggestion on the tip content, please edit this page or add your comments below (do not use the discussion page).

Please discuss whether to keep this as a new tip, or whether to merge it into an existing tip, on the new tips discussion page.
created May 1, 2012 · complexity basic · version 7.0

How to wrap all lines at 80 characters without breaking any words, and preserve shorter lines:

:set formatoptions+=w
:set tw=80
gggqG

Use the following mapping to format the current paragraph:

:nnoremap Q gqip

Comments

What problem are you trying to solve? Inserting hard line breaks in a line which is too long never wraps in the middle of the word. Were you having trouble with the 'wrap' option? Did you not know about it's partner 'linebreak' option?


Related tips:

From :help fo-table:

w Trailing white space indicates a paragraph continues in the next line. A line that ends in a non-white character ends a paragraph.

I'm not familiar with the w option and am not sure if it is doing anything useful in this tip. I guess this tip should be merged to one of those above. JohnBeckett 03:09, May 16, 2012 (UTC)

I think what's useful about this tip is that it explains how to hard-wrap text that's already entered. The "wrap" option only will work on text as it's entered, if I remember correctly. I'm often editing HTML with extremely long lines, so I use this fairly often.Gay Karate Man (talk) 21:09, October 10, 2012 (UTC)

Around Wikia's network

Random Wiki