I know there must be something obvious I'm missing, but I can't stop vim from wrapping my python code. I enter :set nowrap
like a champ, but still it wraps. I can hit J
to unite the split lines of code, so it seems like a real carriage return is being inserted, I just don't understand why or how to stop it.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
'textwidth' 'tw' number (default 0)
local to buffer
{not in Vi}
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. 'textwidth' is set to 0 when the 'paste' option is set. When
'textwidth' is zero, 'wrapmargin' may be used. See also
'formatoptions' and |ins-textwidth|.
When 'formatexpr' is set it will be used to break the line.
NOTE: This option is set to 0 when 'compatible' is set.
'wrapmargin' 'wm' number (default 0)
local to buffer
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.
Options that add a margin, such as 'number' and 'foldcolumn', cause
the text width to be further reduced. This is Vi compatible.
When 'textwidth' is non-zero, this option is not used.
See also 'formatoptions' and |ins-textwidth|. {Vi: works differently
and less usefully}
If you refer to auto wrapping of long lines sending them to the next one, try
:set textwidth=0
:set wrapmargin=0
回答2:
None of the other answers worked for me (IDK why).
:set wrap!
Did the trick for me (using GVim for Windows).
回答3:
set formatoptions-=t
should do the trick. set formatoptions+=t
will turn auto-wrapping back on.
回答4:
Maybe it's the textwidth that's set, which automatically breaks lines when it reaches a certain length Try
:set tw=0
If that fails play with e.g.
:set wrap linebreak textwidth=0
and
:set virtualedit=insert
回答5:
For preventing vim from wrapping long lines I use these two lines in my .vimrc
:
set nowrap " do not automatically wrap on load
set formatoptions-=t " do not automatically wrap text when typing
回答6:
To disable line wrap, you can enter
:set wrap!
or append this command to your ~/.vimrc
.
回答7:
Vim may have to be in vi-compatible mode.
回答8:
Open vimrc_example.vim (Yes, this is the file in Vim74) and set textwidth=0.