Kenny
Kenny

Reputation: 365

Vim: text auto-wrapping doesn't wrap to the next line when it reaches the `textwidth` maximum

Below is my vimrc configuration. I want the text to be wrapped to the next line when it reaches the textwidth maximum.

syntax on
set tabstop=4
set linebreak
set wrap
filetype indent off
set paste
set tw=120
set ruler

I'm using Macbook pro 2014, El Capitan, iterm2.

I have also tried set formatoptions+=cqtrol.

Upvotes: 2

Views: 287

Answers (1)

Ruslan Osmanov
Ruslan Osmanov

Reputation: 21522

This is the effect of set paste. From the Vim help for paste:

When the 'paste' option is switched on (also when it was already on):
    ...
    - 'formatoptions' is used like it is empty

The default value for formatoptions is vt, where t is required for auto-wrapping:

t       Auto-wrap text using textwidth 

Refer to :help fo-table.

So you should remove set paste from your configuration, or unset it temporarily via set nopaste command.

I recommend keeping nopaste by default, i.e. removing set paste, and using the pastetoggle option instead. For example, the following command configures F12 key for toggling the paste mode.

set pastetoggle=<F12>

Upvotes: 1

Related Questions