Dachuan Huang
Dachuan Huang

Reputation: 191

How to check whether vim has enabled line autobreak at 80 characters or not?

Hi my vim automatically insert a newline character after 80 character, which is not my intended behavior. However, I cannot find any line width config in my vimrc file.

How to check whether some config is enabled for this? I want to disable this auto-line-break feature.

Thanks to @romainl reminder, here is the output of the command ":verbose set fo tw":

  formatoptions=tcq                                                                                                                                                      
        Last set from ~/.vim/view/~=+Downloads=+c.txt= line 68                                                                                                           
  textwidth=79                                                                                                                                                           
        Last set from ~/.vim/plugin/python.vim line 20 

Upvotes: 1

Views: 80

Answers (2)

romainl
romainl

Reputation: 196876

So…

  • To reiterate what I wrote in the comments section, automatic line breaks happen when you have t in :help 'formatoptions' and :help 'textwidth' is set to a non-zero value. Individually, those conditions don't lead to automatic line breaks, it is only when they are both true that you get automatic line breaks.
  • The t in formatoptions is not a problem in and of itself. It is part of of the default value anyway so you can pretty much forget about it.
  • You get those automatic line breaks because textwidth is set to 79 in ~/.vim/plugin/python.vim. Change its value to 0 to disable the feature.

But the interaction of those two files is worrying so I think you should take a look at this document.

Upvotes: 1

crushed yogurt
crushed yogurt

Reputation: 61

You might need to configure the following options in your .vimrc

  • wrap
  • textwidth Maximum width of text that is being inserted. A longer line will be broken after white space to get this width. A zero value disables this.
  • wrapmargin Number of characters from the right window border where wrapping starts. When typing text beyond this limit, an EOL will be inserted and inserting continues on the next line.

Upvotes: 0

Related Questions