quicktex


Ⅰ. 插件描述

A vim plugin for writing Latex quickly.

Ⅱ. 基本信息

创建日期:  2016-09-18
使用用户:  31
Github星:  85
插件作者:  Bennett Rennier

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'brennier/quicktex'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'brennier/quicktex'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'brennier/quicktex'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/brennier/quicktex

Ⅳ. 文档说明

## QuickTex is a template expander for quickly writing LaTeX

Before anything else, here's a real-time demonstration of what QuickTex can do:

Basically, QuickTex allows you to set keywords which activate arbitrary Vim code whenever they are typed in insert mode. The expansions are filetype specific and are triggered by pressing space. In most respects, you can think of it like a much-improved version of Vim abbreviations.

How is QuickTex different from UltiSnips or Vim abbreviations?

The main points are simply

  1. QuickTex has a separate namespace for math mode expansions. This will help you type math in Latex faster than you ever thought possible. My math mode dictionary has hundreds of keywords in it, which allow me to pratically type in English and have it converted into pure Latex in real-time.
  2. QuickTex keywords are automatically triggered after a space. This allows you to have seamless expansions that don't slow you down and allow you to type keyword after keyword in rapid sucession.
  3. QuickTex is very fast. Since the code is written completely in Vimscript, QuickTex expands keywords instanteously. Programming similar functionality into a snippets plugin would be significantly slower, especially when you include the context dependence for math mode.

Here's a little table that displays some of the main differences:

FeaturesQuickTexUltiSnipsAbbreviations
Default Trigger Key<Space><Tab>Any non-word character
Cursor PlacementYesYesNo
Default Jump Key<Space><Space>*<C-J>NA
Placeholders<++>InvisibleNA
Available ModesOnly Insert ModeOnly Insert ModeAny mode
Math Mode Context?Yes, very fastPossible, but slowVery difficult to implement
Speed RankingFastestSlowestIn the middle
File Type Specific?YesYesNo

* Requires adding the entry \' ' : "\<ESC>:call search('<+.*+>')\<CR>\"_c/+>/e\<CR>", to your dictionary, which is highly recommended.

Installation

I personally use vim-plug, but here's the various install commands for a variety of plugin managers:

" vim-plug
Plug 'brennier/quicktex'
" NeoBundle
NeoBundle 'brennier/quicktex'
" Vundle
Plugin 'brennier/quicktex'

Configuration

The keywords and their expansions are recorded in various dictionaries. Each filetype has its own dictionary, which should be named in the form of g:quicktex_<filetype>. There is also an additional dictionary that you can use called g:quicktex_math which is used whenever you are inside math delimiters of a Latex file. This example dictionary would give you all the functionality you need for the above gif to work:

let g:quicktex_tex = {
    \' '   : "\<ESC>:call search('<+.*+>')\<CR>\"_c/+>/e\<CR>",
    \'m'   : '\( <+++> \) <++>',
    \'prf' : "\\begin{proof}\<CR><+++>\<CR>\\end{proof}",
\}

let g:quicktex_math = {
    \' '    : "\<ESC>:call search('<+.*+>')\<CR>\"_c/+>/e\<CR>",
    \'fr'   : '\mathcal{R} ',
    \'eq'   : '= ',
    \'set'  : '\{ <+++> \} <++>',
    \'frac' : '\frac{<+++>}{<++>} <++>',
    \'one'  : '1 ',
    \'st'   : ': ',
    \'in'   : '\in ',
    \'bn'   : '\mathbb{N} ',
\}

A few things to note here. If there is a <+++> anywhere in the expansion, then your cursor will automatically jump to that point after the expansion is triggered. Also, while not strictly necessary, I highly advise adding the \' ' : "\<ESC>:call search('<+.*+>')\<CR>\"_c/+>/e\<CR>", entry, which will allow you automatically jump to the next <++> if you press space after a space. You may think this would be annoying to map double space to this, but it's actually extremely useful and doesn't get in the way as much as you'd think. Using this entry, you can put <++>'s in your other expansions to jump around very easily.

Keywords can be any string without whitespace. Expansions can either be a literal string (using single quotes) or a string with keypress expansions (using double quotes). Keypress expansions are things like \<CR>, \<BS>, or \<Right> that one would find in vim remappings. Keep in mind that \'s need to be escaped (i.e. \\) when using double quoted strings and that you need a \ at the beginning of each line of your dictionary.

For more ideas about what to include your dictionary, please take a look at the default dictionaries in ftplugin/tex/default_keywords.vim. It is highly recommended that you make your own custom dictionaries, as the default dictionaries may change without warning.

For more information, read the full documentation using :help quicktex.

添加新评论