Vim 在插入模式下随机添加新行

标签 vim

我是一个相当新的 Vim 用户,我遇到了一些非常烦人的事情,而且我在网上找不到很多东西。当我在 Vim 中进入插入模式并开始输入时,我正在编辑的单词将换行,而不是保留在其原始位置。我可以检查哪些地方来解决这个问题?我将通过我的 .vimrc,但我没有在其中看到任何可能导致问题的内容。

  1 " Turn on line numbers on the side
  2 :set number
  3
  4 " Adjust <Tab> button to be 4 chars long
  5 set softtabstop=4
  6 set shiftwidth=4
  7 set textwidth=4
  8 set expandtab
  9
 10 " Turning on syntax highlighting as adding a filetypes
 11 syntax on
 12 filetype on
 13
 14 " Remappings
 15 inoremap jk <ESC>
 16
 17 set scrolloff=5
 18
 19

最佳答案

你的文本宽度真的很低。

set textwidth=4

这应该设置为更高的值。将它设置为 4 后,在 vim 尝试自动换行之前,该行的大小最多为 4 个字符。

来自 :help 'textwidth'

                                                'textwidth' 'tw'
'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.

From the context of the other settings being set did you mean 'tabstop'. (The size of a tab?)

set tabstop=4

关于Vim 在插入模式下随机添加新行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32030124/

相关文章:

vim - 在 Vim 中捕获 shell 命令的输出

vim 复制/猛拉而不离开可视模式

regex - 如何在vim中用大括号括住视觉上选择的文本

vim - 是否有 Vim 命令来撤消最后一个 Action ,例如<count>j 还是 Ctrl-f?

vim中的正则表达式unicode字符

vim - vim 上的不同配色方案

VIM 自动创建 CTag

vim - 如何使 vim 的方法跳转命令 ']]' 和 '[[' 使用现代方法语法?

vim - Vim 的快速修复列表的 errorformat 中的错误类型是什么?

bash - 为 Go 编程语言设置 vim 自动完成