aszswaz
aszswaz

Reputation: 639

How to turn off automatic line splitting in vim?

I mainly use neovim and I found that setting :set textwidth=0 in ${HOME}/.config/nvim/init.vim has no effect.Textwidth is always 78.

The reason is that other scripts overwrite my settings, I found textwidth=78 in other scripts:

$ sudo find ! -path "./home/**" -name "*.vim" ! -path "./proc" ! -path "./run/**" ! -path "./root/**" | xargs grep "textwidth=78"
./usr/share/nvim/runtime/syntax/ada.vim:"vim: textwidth=78 nowrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab
./usr/share/nvim/runtime/indent/ada.vim:" vim: textwidth=78 wrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab
./usr/share/nvim/runtime/ftplugin/changelog.vim:    setlocal textwidth=78
./usr/share/nvim/runtime/ftplugin/help.vim:setlocal formatoptions+=tcroql textwidth=78
./usr/share/nvim/runtime/ftplugin/javascript.vim:" vim: textwidth=78 tabstop=8 shiftwidth=4 softtabstop=4 expandtab
./usr/share/nvim/runtime/ftplugin/ada.vim:" vim: textwidth=78 nowrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab
./usr/share/nvim/runtime/ftplugin/occam.vim:setlocal textwidth=78
./usr/share/nvim/runtime/compiler/decada.vim:" vim: textwidth=78 wrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab
./usr/share/nvim/runtime/autoload/adacomplete.vim:" vim: textwidth=78 wrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab
./usr/share/nvim/runtime/autoload/decada.vim:" vim: textwidth=78 wrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab
./usr/share/nvim/runtime/autoload/ada.vim:" vim: textwidth=78 wrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab

The number of these scripts is a bit large, I don't want to delete them one by one, and I want to avoid modifying scripts that I don't understand as much as possible.

How should I force automatic line breaking off?

Upvotes: 0

Views: 1126

Answers (1)

Andreas Louv
Andreas Louv

Reputation: 47137

You should take a look at :help fo-table as it's actually your :h 'formatoptions that is responsible to wrap the lines when typing in insert mode, see the t letter.

You can remove the letter with:

set formatoptions-=t

You can identify where an option is set with the :h :verbose command:

:verbose set tw?
  textwidth=80
        Last set from ~/.config/.vim/vimrc line 131
Press ENTER or type command to continue

Upvotes: 1

Related Questions