vim 中自动在换行符处插入文本
我正在使用 vim 编辑 LaTeX 文件。当我在 \begin{itemize}
环境中时,有什么办法告诉 vim 在我打开新行时自动插入 \item
吗?
I am editing a LaTeX file with vim. When I am in the \begin{itemize}
environment, is there any way to tell vim to autoinsert \item
whenever I open a new line?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我知道关于 Latex 的注意事项,但我认为在 vim 脚本中搜索是个好主意
使用左侧的搜索按钮 :D< /a>
例如搜索
乳胶自动完成
I know noting about latex but I think it is a good idea to search in vim scripts
use the search button up left :D
for example search for
latex auto completion
我可以按 Cntl-I,它会以正常模式或插入模式将其放入。这是我在 .vimrc 中放入的内容:
请注意,
\item
末尾有一个空格。I can hit Cntl-I and it'll put it in for me in either normal mode or insert mode. This is what I put in my .vimrc:
Note that there is a space at the end of
\item
.我破解了 ZyX 提供的脚本并想出了这个。它添加了对
o
和O
命令的支持。它不需要需要LaTeX-VIM。I hacked the script ZyX supplied and came up with this. It adds support for the
o
andO
commands. It does not require LaTeX-VIM.Samad Lotia 和 ZyX 的答案的扩展版本
将其放入
~/.vim/after/ftplugin/tex.vim
Improvements
\item< /code> 也适用于环境
enumerate
和description
\item
仅当直接周围环境是以下三个环境之一时才会发生 (逐项/枚举/描述
)。在以下情况下不会发生\item
仅当您在行尾< 删除自动插入的
。如果想在这种情况下添加一些缩进,请将\item
时才会发生第二次;CR>''
更改为''
>。Extended Version of Answer by Samad Lotia and ZyX
Place this in your
~/.vim/after/ftplugin/tex.vim
Improvements
\item
also happens for environmentsenumerate
anddescription
\item
only happens if the immediate surrounding environment is one of the three (itemize/enumerate/description
). It does not happen in following circumstance\item
only happens if you are at the end of the line\item
by pressing<CR>
a second time. If one wants to add some indention in this case, change'<c-w><c-w>'
to'<c-w><c-w><c-t>'
.将其放入
.vim/ftplugins/tex.vim
文件(或.vim/ftplugins/tex
目录中的任何.vim
)中。Put this into your
.vim/ftplugins/tex.vim
file (or any.vim
inside.vim/ftplugins/tex
directory).我推荐 http://vim-latex.sourceforge.net。这个包定义了几个对 Latex 有用的贴图。
特别是要插入 \item,请按
I would recommend http://vim-latex.sourceforge.net. This package defines several maps useful for latex.
In particular for inserting \item you press
<ATL-I>