Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
固定段落中的行溢出,在VIM中给定一组textwidth_Vim_Vim Plugin - Fatal编程技术网

固定段落中的行溢出,在VIM中给定一组textwidth

固定段落中的行溢出,在VIM中给定一组textwidth,vim,vim-plugin,Vim,Vim Plugin,让我们假设my.vimrc具有以下配置: 设置textwidth=10 在文件中,我键入以下内容: This is a sentence word wraps just fine at 10 chars. 当我输入这个句子时,VIM会实时自动换行,防止我通过我设置的标记。然而,我发现自己面临的一个常见问题是添加更多内容。我忘记了上一段中的一个词,“那个词所包含的句子。” 所以我回去加上它 This is a a sentence that, suddenly, doesn't word w

让我们假设my.vimrc具有以下配置:

设置textwidth=10

在文件中,我键入以下内容:

This is a 
sentence
word wraps
just fine
at 10 
chars.
当我输入这个句子时,VIM会实时自动换行,防止我通过我设置的标记。然而,我发现自己面临的一个常见问题是添加更多内容。我忘记了上一段中的一个词,“那个词所包含的句子。”

所以我回去加上它

This is a
a sentence that, suddenly, doesn't
word wrap
just fine
at 10
chars.
如果我现在想解决这个问题(所有行都低于我设置的10个字符的限制),我必须找到10个字符的位置,点击RETURN(向下移动额外内容),然后在下一行找到10个字符的位置,点击RETURN,依此类推

在代码中的程序和函数序言中(我通常使用73个字符的行限制),这个场景对我来说很常见,因为我发现自己以后不得不添加更多的解释或内容

有没有快速/简单的方法解决此问题

此外:

我在我的
.vimrc
中有此选项以突出显示文本宽度:

" highlight anything past the 73 character limit
augroup vimrc_autocmds
    autocmd Filetype cpp autocmd BufEnter * highlight OverLength ctermbg=darkgrey guibg=#592929
    autocmd Filetype cpp autocmd BufEnter * match OverLength /\%73v.*/
augroup END

也许我也可以补充一些东西

您可以使用
gq
命令重新格式化受影响的行。通常,
gqap
(段落格式)可以,如果不能,可以使用视觉模式或动作


您也可以在使用
:set formatoptions+=a
键入时使Vim连续重新格式化,但这对我来说从来都不起作用。

Vim手动输入
:表格帮助
报告:

l       Long lines are not broken in insert mode: When a line was longer than
        'textwidth' when the insert command started, Vim does not
        automatically format it.
由于您在评论中说
formatoptions
包含字母
l
,因此应使用以下命令打开此选项:

:set formatoptions-=l

要修复现有行,正如Ingo已经建议的那样,您可以使用
gq
命令,该命令将遵守
textwidth
设置。

设置格式选项的输出是什么?
太棒了,正是我需要的!