我喜欢长线显示在多个终端线;我不喜欢vim插入换行到我的实际文本。我应该修改。vimrc的哪一部分?
当前回答
正确的是,set nowrap将允许你粘贴一个长行,而不需要vi/vim添加换行符,但这样行就不会被视觉上的换行以方便阅读。相反,它只是一个长长的行,你必须滚动。
要使行在视觉上换行但不插入换行符,请设置wrap(这可能是默认设置,因此不需要设置)并设置textwidth=0。
在某些系统上,textwidth=0的设置是默认的。如果您发现情况并非如此,请将set textwidth=0添加到您的.exrc文件中,以便它成为所有vi/vim会话的用户默认值。
其他回答
如果像我一样,你在Windows上运行gVim,那么你的.vimrc文件可能是另一个“示例”Vimscript文件,它会自动设置文本文件的文本宽度(在我的例子中是78)。
我在Vi和Vim Stack Exchange站点上回答了一个类似的问题——如何停止gVim在第80列包装文本:
In my case, Vitor's comment suggested I run the following: :verbose set tw? Doing so gave me the following output: textwidth=78 Last set from C:\Program Files (x86)\Vim\vim74\vimrc_example.vim In vimrc_example.vim, I found the relevant lines: " Only do this part when compiled with support for autocommands. if has("autocmd") ... " For all text files set 'textwidth' to 78 characters. autocmd FileType text setlocal textwidth=78 ... And I found that my .vimrc is sourcing that file: source $VIMRUNTIME/vimrc_example.vim In my case, I don't want textwidth to be set for any files, so I just commented out the relevant line in vimrc_example.vim.
Use
:set wrap
可视化地换行,即该行仍然是一行文本,但Vim将其显示为多行。
Use
:set nowrap
将长行显示为一行(即,您必须水平滚动才能看到整行)。
我个人认为:
包装, 设置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。
:设置tw = 0
VIM不会自动插入换行符,但会保持换行。
奇怪的是,如此简单的设定却需要如此多的“恶作剧”才能奏效。
现在回答你的问题,对我来说,它似乎与以下几个方面相结合:
:set wrap linebreak nolist
(这似乎可以防止现有的线断裂,只是包装。)
AND
set formatoptions=l
(这可以防止新的/编辑的行中断,而+=并不为我这样做,因为其他设置/插件似乎找到空间,并添加他们自己的选项,覆盖我的。)
推荐文章
- 如何在Vim注释掉一个Python代码块
- 如何在可视块模式插入?
- 强迫自己掌握vi的最好方法是什么?
- 如何回到行之前编辑的最后一个在Vim?
- 如何跳转到一个特定的人物在vim?
- 如何删除一个大的文本块而不计算行?
- 在Vim/Vi中,如何将光标移动到前一个单词的末尾?
- 如何在vim中自动删除尾随空格
- 为什么Vim使用~扩展名保存文件?
- 如何在Vim或Linux中将空格转换为制表符?
- 我如何使用vimdiff来解决git合并冲突?
- 在Vim中删除当前缓冲区的文件名/路径
- Git在终端提交时打开VIM,但无法返回终端
- 请参阅编辑器中的换行符和回车
- 如何在NERDTree中显示隐藏文件(以句点开始)?