智能硬包装,用于vim中的项目列表

时间:2012-06-20 08:03:21

标签: vim

我喜欢vim,我真的很想在写作时把文字包好。来自Tim Pope的降价插件非常棒,而且当我尝试硬包装物品清单时,它就能完成工作。好的,我的意思是做正确的工作:

- here I write a long long long line that is longer than the 80 caracters of a line and therefore should be wrapped.
- This is a short line
- here I write another long long long line that is longer than the 80 caracters of a line and therefore should be wrapped.

应该成为(在应用gqap之后):

- here I write a long long long line that is longer than the 80 caracters
  of a line and therefore should be wrapped.
- This is a short line
- here I write another long long long line that is longer than the 80 caracters
  of a line and therefore should be wrapped.

现在,具有tex文件类型的文本的相同命令的行为不是那么聪明:

\begin{itemize}
\item here I write a long long long line that is longer than the 80 caracters I fixed and therefore should be wrapped.
\item This is a short line
\item here I write another long long long line that is longer than the 80 caracters I fixed and therefore should be wrapped.
\end{itemize}

成为(仍然在gqap之后):

\begin{itemize} \item here I write a long long long line that is longer than
        the 80 caracters I fixed and therefore should be wrapped.  \item This
        is a short line \item here I write another long long long line that is
        longer than the 80 caracters I fixed and therefore should be wrapped.
\end{itemize}

如何在LateX中包装项目列表的行为类似于降价列表?

对我来说,看起来我应该重新定义语法文件,但我不知道如何(markdown的工作方式是使用为HTML定义的元素)。

1 个答案:

答案 0 :(得分:6)

配置

:set fo+=n
:let &flp='^\s*\\\w*\s*'

输入

\begin{itemize}
    \item here I write a long long long line that is longer than the 80 caracters I fixed and therefore should be wrapped.
    \item This is a short line
    \item here I write another long long long line that is longer than the 80 caracters I fixed and therefore should be wrapped.
\end{itemize}

gggqG


输出

\begin{itemize}
    \item here I write a long long long line that is longer than the 80
          caracters I fixed and therefore should be wrapped.
    \item This is a short line
    \item here I write another long long long line that is longer than the 80
          caracters I fixed and therefore should be wrapped.
\end{itemize}
相关问题