vim-ftplugins


Ⅰ. 插件描述

A collection of tools useful for editing LaTeX manuscripts

Ⅱ. 基本信息

创建日期:  2019-04-19
使用用户:  1
Github星:  1
插件作者:  Luke Davis

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'lukelbd/vim-ftplugins-hard-things'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

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

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'lukelbd/vim-ftplugins-hard-things'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'lukelbd/vim-ftplugins-hard-things'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

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

Ⅳ. 文档说明

# LaTeX tools
This is a collection of custom tools and plugin enhancements for working with LaTeX files in vim, similar to vimtex.

It includes integration with the vim-text-obj, surround.vim, delimitMate, and citation.vim plugins that make editing LaTeX documents a breeze, and a custom latexmk script that omits some features from the more ubiquitous program of the same name and adds useful new features. It also adds a templating engine -- when you open a new .tex file, a popup window allows you to load arbitrary .tex file templates stored in a ~/latex folder. This requires the FZF vim plugin.

This set of tools is complex and would take quite a while to document. For now I will just give a broad summary of the features and expect any users to dig into the vimscript code to get the full picture.

<!--

Commands

  • :TabToggle: Toggles expandtab on-and-off.
    -->

<!--

Syntax highlighting

  • Added support for MATLAB, NCL, and "awk" script syntax highlighting. See
    files in the syntax folder.
  • Added support for highlighting SLURM and PBS supercomputer directives in comments at
    the head of shell scripts. See after/syntax/sh.vim.
  • Improved the default python and LaTeX highlighting. See
    syntax/python.vim and after/syntax/tex.vim.
  • Improved comment highlighting for fortran and HTML syntax.
    See files in the after/syntax folder.

-->

<!--

Filetype settings

  • For most languages, added a normal mode <C-z> map
    for "running" the current file. See files in the ftplugin folder.
  • For LaTeX documents, this relies on having my custom script for typesetting documents,
    https://github.com/lukelbd/dotfiles/blob/master/vimlatex, somewhere in your $PATH.

-->

Documentation

Commands

CommandDescription
:LatexmkRuns the custom latexmk script. This typesets the document asynchronously, shows a condensed log in a popup split window, and opens the file in the Skim PDF viewer). It automatically detects the number of times the typesetting command must be called, like the original latexmk, automatically figures out which typesetting engine to use based on the packages imported, automatically copies over custom user style and theme files from a ~/latex folder, and deletes extra files generated during typesetting. Run :Latexmk --help for more info.
:BibtexToggleToggles between citation.vim using bibtex or Zotero for retrieving citations for the current file. The default is bibtex.

Mappings

MappingDescription
<C-z><key>These are maps for inserting text snippets in insert mode (see surround.vim for details). Example usage includes running <C-z>a in a LaTeX document to insert the LaTeX alpha character \alpha.
<C-s><key>, ys<obj><key>, ...New surround.vim delimiter mappings. These are custom delimiters integrated with the surround.vim plugin, introducing a series of insert, visual, and normal mode maps (see surround.vim for details). Example usage includes making a visual selection in a LaTeX document then pressing <C-s>* to surround with a \begin{itemize} \end{itemize} environment, or running yswb in normal mode to surround the word under the cursor with a \textbf{} command.
va<key>, vi<key>, ...New text object mappings. These are custom delimiters integrated with the vim-textobj-user plugin for selecting, yanking, changing, and deleting blocks of text with va<key>, ya<key>, etc (see textobjs.vim for details). Example usage includes selecting a LaTeX \begin{} \end{} environment with vaT, or changing text inside a LaTeX command with cit.
<C-b><key>New citation insert mappings. These insert citations from a local bibliography or from your Zotero sqlite database (see citation.vim for details). Adds ability to use bibliographies local to specific buffers.
<C-h>, <C-l>Jumps to the right of the previous, next bracket in insert mode (i.e. any of the characters []<>(){}). This is handy when the cursor is inside a complex next of varying types of delimiters, a common difficulty when writing LaTeX equations. It stands in contrast to delimitMate's <Plug>delimitMateJumpMany map, which jumps to the far outside of nested delimiters.

Functions

FunctionDescription
textools#delete_delimsDeletes arbitrary delimiters around the cursor. Arguments are a left delimiter regex and a right delimiter regex. This is best used in a normal mode mapping that looks like ds<key>.
textools#change_delimsChanges arbitrary delimiters. Arguments are a left delimiter regex, right delimiter regex, and a replacement indicator. This can be a non-empty string, used for both left and right delimiters, or an empty string, in which case the function reads the next character pressed by the user and uses the corresponding delimiter. This is best used in a normal mode mapping that looks like cs<key>.

Customization

OptionDescription
g:textools_delim_prefixPrefix for the insert mode and visual mode vim-surround mappings. The default is <C-s>, which is intuitive but requires adding bind -r '"\C-s"' to your ~/.bashrc or ~/.bash_profile.
g:textools_snippet_prefixPrefix for the snippet insert mappings. The default is <C-z>.
g:textools_citation_prefixPrefix for the citation insert mappings. The default is <C-b>.
g:textools_citation_mapsDictionary of citation insert mapping suffixes and LaTeX cite commands. The default is let g:textools_citation_maps = {'c':'', 't':'t', 'p':'p', 'n':'num'}, which inserts \cite{ref} when <C-b>c is pressed, \citet{ref} when <C-b>t is pressed, etc.
g:textools_prevdelim_mapInsert mode mapping for jumping to the previous bracket. The default is <C-h>.
g:textools_nextdelim_mapInsert mode mapping for jumping to the previous bracket. The default is <C-l>.
g:textools_latexmk_mapsDictionary of normal mode mappings and flags for the :Latexmk. This is empty by default. For example, let g:textools_latexmk_maps = {'<C-x>':'', '<Leader>x':'--diff'} adds maps that call :Latexmk with no flags and the --diff flag.

Installation

Install with your favorite plugin manager.
I highly recommend the vim-plug manager. To install with vim-plug, add

Plug 'lukelbd/vim-textools'

to your ~/.vimrc.

See also

If you find this plugin useful, I also highly recommend
two other tools I developed:

  • My vim-scrollwrapped plugin, which toggles "wrapped" lines automatically for non-code documents (like markdown, RST, and LaTeX files) and makes scrolling through vim windows with heavily wrapped lines much, much easier.
  • My ctags preference file, which contains a bunch of new definitions for marking section, figure, table, etc. locations with ctags.
  • My idetools plugin, which includes various refactoring commands and tools for jumping around documents based on ctags locations.

添加新评论