Previously, I haven't set textwidth in .vimrc and it was no autowrapping by default in all files. At some point (probably after an upgrade) it stared to do autowrap, but only for *.txt files, i.e. if I open such file and enter the command :set tw I get textwidth=78 Of course, I can set it manually to 0, but it'll be forgotten on the next run. So, I've added this string to my ~/.vimrc: set textwidth=0 But it turned out, that this doesn't change the behaviour at all. I've tested with latest versions for amd64 and ~amd64, i.e. 7.4.769 and 7.4.827. Reproducible: Always Steps to Reproduce: 1. echo 'set textwidth=0' >> ~/.vimrc 2. vim textfile.txt 3. type ":set textwidth" Actual Results: textwidth=78 Expected Results: textwidth=0
I've found where it comes from. This part of /etc/vim/vimrc: 159 " In text files, limit the width of text to 78 characters, but be careful 160 " that we don't override the user's setting. 161 autocmd BufNewFile,BufRead *.txt 162 \ if &tw == 0 && ! exists("g:leave_my_textwidth_alone") | 163 \ setlocal textwidth=78 | 164 \ endif It says, that it should not override the user's settings, but it does. Also, a few lines above it says, that it's one of the Gentoo-specific settings for ebuilds. But txt files are not ebuilds. The link with "more information" points to the page 404. I suggest to just remove this part of /etc/vim/vimrc The workaround is: echo 'let g:leave_my_textwidth_alone=1' >> ~/.vimrc
Really helpful workaround. Thank you. =)
Hi I haven't been able to reproduce this bug. Here's what I set in my ~/.vimrc file: set textwidth=79 and it is actually equal to 79 if I query it in vim. Maybe something is up in your setup? Somebody else in this bug report pointed out a workaround. Hopefully it helps solve this problem.
The `&tw == 0` part prevents this autocommand from changing the value of 'textwidth' if it has been overridden by the user. All the autocommand does is change the default value of 'textwidth' from 0 [1] to 78 for *.txt files. However, I don't think this is a good idea to override the defaults. Keeping lines short is a *preference* that only applies to certain types of files (mostly code source files, none of which have the .txt extension). I think this autocommand should either be modified to only apply to *.e{build,class} files (as the command above it) [2][3], or it should be removed entirely. [1]: https://vimhelp.org/options.txt.html#%27textwidth%27 [2]: https://github.com/gentoo/gentoo/blob/e1a7e5da58ec33213c680337f4240e75c5e300a4/app-editors/vim-core/files/vimrc-r6#L158 [3]: https://github.com/gentoo/gentoo/blob/e1a7e5da58ec33213c680337f4240e75c5e300a4/app-editors/neovim/files/sysinit.vim#L58
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6fe17e177a8b6146cb6307dd1325b6a474e7991b commit 6fe17e177a8b6146cb6307dd1325b6a474e7991b Author: Waldo Lemmer <waldolemmer1@gmail.com> AuthorDate: 2024-05-08 19:21:22 +0000 Commit: Mike Gilbert <floppym@gentoo.org> CommitDate: 2024-05-19 15:28:37 +0000 app-editors/vim-core: remove textwidth autocommands vimrc registered an autocommand that set textwidth=78 for all *.txt buffers. This has sparked a few discussions, including this [1] forum post and bug 559800. Overriding the upstream default of textwidth=0 is not a good idea. This commit removes the relevant autocommand and revbumps all versions of the package. [1]: https://forums.gentoo.org/viewtopic-p-8450986.html Closes: https://bugs.gentoo.org/559800 Signed-off-by: Waldo Lemmer <waldolemmer1@gmail.com> Signed-off-by: Mike Gilbert <floppym@gentoo.org> app-editors/vim-core/files/vimrc-r7 | 210 ++++++++++++++++++++ app-editors/vim-core/vim-core-9.0.1503-r1.ebuild | 231 ++++++++++++++++++++++ app-editors/vim-core/vim-core-9.0.1627-r1.ebuild | 231 ++++++++++++++++++++++ app-editors/vim-core/vim-core-9.0.1678-r1.ebuild | 231 ++++++++++++++++++++++ app-editors/vim-core/vim-core-9.0.1777-r1.ebuild | 231 ++++++++++++++++++++++ app-editors/vim-core/vim-core-9.0.2092-r1.ebuild | 231 ++++++++++++++++++++++ app-editors/vim-core/vim-core-9.0.2167-r1.ebuild | 236 +++++++++++++++++++++++ app-editors/vim-core/vim-core-9.1.0366-r1.ebuild | 236 +++++++++++++++++++++++ app-editors/vim-core/vim-core-9999.ebuild | 2 +- 9 files changed, 1838 insertions(+), 1 deletion(-) Additionally, it has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a47c50d2df50ed5b07a286bcef267a76967235ae commit a47c50d2df50ed5b07a286bcef267a76967235ae Author: Waldo Lemmer <waldolemmer1@gmail.com> AuthorDate: 2024-05-08 19:27:00 +0000 Commit: Mike Gilbert <floppym@gentoo.org> CommitDate: 2024-05-19 15:28:47 +0000 app-editors/neovim: remove textwidth autocommands vimrc registered an autocommand that set textwidth=78 for all *.txt buffers. This has sparked a few discussions, including this [1] forum post and bug 559800. Overriding the upstream default of textwidth=0 is not a good idea. This commit removes the relevant autocommand and revbumps all versions of the package. [1]: https://forums.gentoo.org/viewtopic-p-8450986.html Bug: https://bugs.gentoo.org/559800 Signed-off-by: Waldo Lemmer <waldolemmer1@gmail.com> Closes: https://github.com/gentoo/gentoo/pull/36602 Signed-off-by: Mike Gilbert <floppym@gentoo.org> app-editors/neovim/files/sysinit.vim-r1 | 97 ++++++++++++++++++++++++ app-editors/neovim/neovim-0.9.4-r1.ebuild | 115 ++++++++++++++++++++++++++++ app-editors/neovim/neovim-0.9.5-r1.ebuild | 120 ++++++++++++++++++++++++++++++ app-editors/neovim/neovim-9999.ebuild | 2 +- 4 files changed, 333 insertions(+), 1 deletion(-)