在Latex文档中的Vim中的单词换行(保留缩进)

问题描述 投票:1回答:1

我只是看着this帖子,它描述了如何用vim包装整个单词。我正在寻找一种方法来键入缩进,或者在我的情况下,缺少它。

我通常用V选择几行,然后按gq重新格式化它并重新包装线条。

比方说,我有以下文件

 *Inside of window                        *Outside of window
|---------------------------------------|    
|This is a bla like of text that will wr|ap here                            
|can you see the wrap                   |
|                                       |
|---------------------------------------|

结果将是:

 *Inside of window                        *Outside of window
|---------------------------------------|    
|This is a bla like of text that will   |                            
|wrap here can you see the wrap         |
|                                       |
|---------------------------------------|

到现在为止还挺好。

现在让我们说,我有以下文件和一些乳胶标签

 *Inside of window                        *Outside of window
|---------------------------------------|    
|\begin{abstract}                       |
|This is a bla like of text that will wr|ap here                            
|can you see the wrap                   |
|\end{abstract}                         |
|                                       |
|---------------------------------------|

结果如下,其中包含下一行中不需要的\t

 *Inside of window                        *Outside of window
|---------------------------------------|    
|\begin{abstract}                       |
|This is a bla like of text that will   |
|    wrap here can you see the wrap     |
|\end{abstract}                         |
|                                       |
|---------------------------------------|

但是,我的目标是得到如下结果,在下一行没有不受欢迎的\t

 *Inside of window                        *Outside of window
|---------------------------------------|    
|\begin{abstract}                       |
|This is a bla like of text that will   |
|wrap here can you see the wrap         |
|\end{abstract}                         |
|                                       |
|---------------------------------------|

我尝试将set breakindent添加到我的.vimrc但它没有用。目前这些是我用于包装的线。

set wrap                                    " Wrap                                 
set textwidth=79                            " Default Text Width
vim word-wrap tex
1个回答
0
投票

乳胶的缩进由GetTeXIndent()函数决定(可以通过:setlocal indentexpr?找到)。 $VIMRUNTIME/indent/tex.vim中的相应脚本在其标题中包含文档。它提到(以及其他)一个影响环境缩进的配置设置。

" * g:tex_noindent_env
"
"   A list of environment names. separated with '\|', where no indentation is
"   required. The default is 'document\|verbatim'.

如果你在那里添加\begin{...}项目(通过将配置放入你的~/.vimrc),不会发生额外的缩进:

let g:tex_noindent_env .= '\|begin'

警告:我对Latex语法知之甚少;这可能会对其他地方的格式化造成不良副作阅读整个缩进文档,了解调整它的选项。

© www.soinside.com 2019 - 2024. All rights reserved.