Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I prevent vim from auto-wrapping at column 80

Tags:

vim

As I'm writing code, when the cursor reaches column 80, vim automatically wraps the text by inserting a newline character. How do I prevent vim from doing so? Is there any setting that am missing?

like image 756
Aswin Anand Avatar asked Mar 31 '13 00:03

Aswin Anand


People also ask

How do I turn off 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 I set 80 characters per line in Vim?

As of vim 7.3, you can use set colorcolumn=80 ( set cc=80 for short).

How do I turn on line wrap 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. The following sets a wrap margin of 2 characters from the right window border.

What is Nowrap in Vim?

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).


2 Answers

The auto-wrapping is defined by set wrap and this option depends on the width of your window/screen, but it does not insert a newline character into the file.

The column 80 is defined by set tw=80 this will change the text by adding new linebreaks for long lines.

To check details, you can:

:h 'wrap'
:h 'tw'

To disable auto-wrapping, you could:

:set nowrap

To disable long line auto broken, you can:

:set tw=0

0 is default.

like image 128
Kent Avatar answered Sep 28 '22 16:09

Kent


Just found that set tw=0 works. It doesn't wrap lines by inserting a new line character at a predefined limit.

Added that set to vimrc to make it permanent.

like image 41
Aswin Anand Avatar answered Sep 28 '22 16:09

Aswin Anand