Let's speak of relative measures. My Vim looks like:
aaaaaaaaaaaaa bbbbbbbbbbbbb ccccccccccccc etc
I would like it to be smaller:
aaaaa aaaaa bbbbb bbbbb ccccc ccccc etc
How can I get it? And how can I manage setting the length of such a block?
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.
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.
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).
In the gedit Text Editor menu click Edit, and then click Preferences. A popup named gedit Preferences opens up. In the same popup on the first Tab named View, under the sub-heading Text Wrapping click the check box named Enable text wrapping, to toggle the text wrap feature on or off.
You can actually do two things:
Which do you want?
Option 1 would be achieved by setting textwidth
(for example :set textwidth=30
(from Swaarop's answer)). Then you can reformat your text by highlighting it (in visual mode) and typing gq
. (textwidth
can be abbreviated as tw
, thus :set tw=30
.)
Option 2 can be toggled by running :set wrap
/ :set nowrap
. This will wrap lines which are too long for the window.
Both are independent.
Once you set 'textwidth', you can select text with visual mode and press gq to wrap it nicely (you can also use Q on some older/legacy configurations).
A few useful tips:
gqq (wrap the current line) gq} (wrap this 'paragraph', i.e. until the next blank line) :h gq
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With