2024-07-07 10:00:02

如何停止断行在vim

我喜欢长线显示在多个终端线;我不喜欢vim插入换行到我的实际文本。我应该修改。vimrc的哪一部分?


当前回答

使用:set nowrap ..效果好极了!

其他回答

使用:set nowrap ..效果好极了!

我喜欢在多个终端行上显示长行

这种可视/虚拟行换行是由wrap window选项启用的:

:set wrap

默认情况下,这将在窗口中不适合的第一个字符处换行。这意味着如果窗口边界位于单词的中间,它将自动换行。要将其更改为按单词边界换行,您还可以:

:set linebreak

这将导致换行只对换行符设置中的字符进行换行,该设置默认为空格、制表符和一小组标点符号。

:set breatat
  breakat= ^I!@*-+;:,./?

我不喜欢vim插入换行到我的实际文本。

要关闭物理行换行,请清除textwidth和wrapmargin缓冲区选项:

:set textwidth=0 wrapmargin=0

set formatoptions-=t保持视觉文本宽度,但不会在插入模式中添加新行。

我个人认为:

包装, 设置linebreak 设置breakindent 设置showbreak =ͱ。

这里做一些解释:

wrap option visually wraps line instead of having to scroll horizontally linebreak is for wrapping long lines at a specific character instead of just anywhere when the line happens to be too long, like in the middle of a word. By default, it breaks on whitespace (word separator), but you can configure it with breakat. It also does NOT insert EOL in the file as the OP wanted. breakat is the character where it will visually break the line. No need to modify it if you want to break at whitespace between two words. breakindent enables to visually indent the line when it breaks. showbreak enables to set the character which indicates this break.

参见:h <关键字>在vim中获得更多信息。

注意,如果您采用这种方法,则不需要修改textwidth和wrapmargin。

奇怪的是,如此简单的设定却需要如此多的“恶作剧”才能奏效。

现在回答你的问题,对我来说,它似乎与以下几个方面相结合:

:set wrap linebreak nolist

(这似乎可以防止现有的线断裂,只是包装。)

AND

set formatoptions=l

(这可以防止新的/编辑的行中断,而+=并不为我这样做,因为其他设置/插件似乎找到空间,并添加他们自己的选项,覆盖我的。)