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

2024-04-20

我喜欢 vim,而且我真的很喜欢在写文字时将它们硬包装起来。 Tim Pope 的 markdown 插件很棒,并且构建得当我尝试硬包装项目列表时它可以正确完成工作。好吧,这就是我所说的正确完成工作的意思:

- 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 列表一样?

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


config

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

input

\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}

type

gggqG.


output

\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}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

vim 中项目列表的智能硬包装 的相关文章

  • dos2unix 不转换 ^M

    我从 Windows 7 上运行的程序将结果导出到文本文件中 并在 Xubuntu 14 04 上复制该文件 在终端中 我跑了dos2unix file txt 这告诉我converting file out mapqtl txt to U
  • Vim: set langmap=e;h 破坏 supertab 插件

    我是 Vim 新手 正在尝试设置一些插件 到目前为止我已经安装了 Pathogen pyflakes 和 supertab 后者似乎不起作用 紧迫tab而在插入模式下只需写入字符串
  • vim 中的切换功能

    基本上我想做的是 map e call ToggleEssayMode
  • 如何“重写”现有的 vim 键绑定?

    I want to assign CTRL L to go the next tab tabnext I placed it at vimrc nmap
  • Vim 和 Ctags:生成标签时忽略某些文件

    我有一个文件夹 llvm2 9 我在其中运行了此命令 gt ctags R sort 1 c kinds p fields iaS extra q language force C 这是 html 文件中的索引方法 也存在于 llvm2 9
  • 你能强制 Vim 在文件末尾显示一个空行吗?

    当我在记事本中打开文本文件时 如果包含文本的最后一行末尾有回车符 则会显示一个空行 然而 在 Vim 中它不显示这个空行 我注意到的另一件事是 Vim 编辑器默认在最后一行添加回车符 即使它没有显示 我可以这么说 因为如果我在记事本中打开在
  • 如何让 git 在 vi​​m 中显示更改,就像 hg 使用 hgeditor 脚本那样?

    Mercurial 的一个有趣的功能是能够查看将在 vim split 中提交的更改 请参阅VIM 中的 DiffsInCommitMessage https www mercurial scm org wiki DiffsInCommit
  • 如何在vim中每隔几行添加一行

    我想使用 vim 编辑器在文件 大约 1000 行 中每 3 行添加一行 有人可以帮我吗 谢谢 艾丽莎 有一个 vim 特定的正则表达式可以做到这一点 s n n n 0 r g s 是 vim ex 命令来替换整个文件 n 是包含行尾的一
  • 选项卡视觉选择

    In many GUIs when I select a section of text and then hit the Tab or Shift Tab button the selected section will indent i
  • vim 脚本:如何在 vim 函数中执行命令

    为什么会出现以下情况 let s colorschemes synic ir black let s colorscheme idx 0 function RotateColorscheme let s colorscheme idx 1
  • 有没有一个 vim 命令可以重新定位选项卡?

    如何更改当前选项卡的位置 顺序Vim 例如 如果我想将当前选项卡重新定位为第一个选项卡 您可以使用以下命令重新定位选项卡 tabm使用相对或零索引绝对参数 绝对 将选项卡移至位置 i tabm i 相对的 将选项卡 i 位置向右移动 tab
  • 切换 git 分支时如何处理 vim 缓冲区?

    因此 我在 vim 缓冲区中打开了大量文件 并且正在使用 git 处理功能分支 突然 我意识到我需要恢复到主分支来进行快速修复 提交后 我将 vim 会话保持打开状态并切换回 master 分支 但是 当我尝试从缓冲区加载我需要的文件时 我
  • 有没有办法用 Vim 自动重新格式化大括号?

    我想重新格式化一些代码 如下所示 if cond foo to if cond foo 由于这是C代码 所以我一直在看cindent cinoptions与使用 但它似乎不处理多行规则 我一直在看formatoptions与使用gq 而且似
  • 当vim进入可视模式时运行命令

    我使用一个小脚本来触发插入模式以更改行号颜色 function CursorLineNrColorInsert mode Insert mode blue if a mode i highlight CursorLineNr ctermfg
  • Vim 关闭窗口而不关闭缓冲区

    如何在不删除缓冲区的情况下关闭窗口或取消分割 A window is a viewport on a buffer In vim to manage windows it is CTRL w the leading command that
  • 在 Vim 中的缩进线上按“Home”

    我有一个坏习惯 就是使用 home 键返回到行首 当我最近开始使用 vim 时 我注意到当我在缩进的行上按 home 键时 它会让我回到该行的开头 在 Notepad 我曾经使用的编辑器 中 它会让我返回到该行代码的开头 就在缩进之后 有没
  • Vim / vi 生存指南

    基本的 vim 命令有哪些 新用户需要了解什么才能避免陷入麻烦 请每条评论一条命令 我发现不可替代的 因为它也可以在 vi 中使用 与 vim 的视觉模式不同 是标记 您可以用以下标记标记不同的点m 小写 然后是您选择的字母 例如 x 然后
  • 带有 Viper 和 Vimpulse 的 Emacs 缺少哪些 Vim 功能?

    Emacs 的一些重要功能在 Vim 中是缺失的 例如 comint 模式 并且没有脚本 插件可以替代它们 与 Emacs 相比 Vim 也有一些优点 例如模式编辑和通常更好的默认快捷键 然而 Viper 模式让我两者兼而有之 Vimpul
  • Redhat Vim 中的可视化块插入

    我的 ec2 服务器附带了 redhat vim ec2 user vim version VIM Vi IMproved 7 2 2008 Aug 9 compiled Jul 7 2012 08 03 48 Included patch
  • 使用 vim 重构目录中的类/方法/字符串的有效方法

    到目前为止 我一直在使用查找和替换操作手动重构代码 s stringiwanttoreplace newstring g in vim 但这是一个缓慢而费力的过程 如果我有的话字符串我想更换在特定目录内的许多文件中 我当前 典型的缓慢而费力

随机推荐