Giter Club home page Giter Club logo

vim-latexfmt's Introduction

LaTeXFmt is a LaTeX-aware Vim formatter.


LaTeXFmt is a vim plugin for formatting paragraphs and other text selections in LaTeX files. It allows fine-grained control over lines containing keywords, commands, and environments. Here's an example:

Before creating this gif, I mapped 'K' to <Plug>latexfmt_format. In absence of a count or visual selection, the command formats the current paragraph. One might note several things about the way the paragraphs are formatted:

  1. In the first paragraph, nothing inside the align environment is formatted. That behavior is customizable, however.
  2. In the second paragraph, the individual items in the itemize environment are formatted while newlines after each item are retained. That behavior is also customizable.
  3. In both paragraphs, the cursor is at the same 'logical' position after formatting as before.
  4. In both paragraphs, multiple spaces outside the align environment collapse to a single space (except at the ends of sentences).

Installation

If you use pathogen or the native vim package manager, simply clone this repository to the appropriate directory. If you're using a more configurable package manager, you'll know what to do.

Configuration

LaTexFmt takes its instructions for how to format from a set of lists. To reproduce the behavior above, it is enough to define, in your .vimrc or elsewhere in your runtime path,

let g:latexfmt_no_join_any = [ '%', '\begin, '\end', '\vspace', '\noindent' ] 

let g:latexfmt_no_join_prev = [ '\item' ] 

let g:latexfmt_verbatim_envs = [ 'align' ] 

The first list contains strings that prevent lines containing them from joining the following or previous lines, the second contains strings that prevent them from joining the previous lines but allow them to join the following lines (there is also a list named g:latexfmt_no_join_next that does the opposite), and the third contains environments that LaTeXFmt leaves completely alone. The default lists include more strings than those here, but are still pretty minimal. You'll probably want to construct your own lists.

Acknowledgment

This plugin is essentially a rewrite and extension of the inspirational script by 'lpb612,' at https://www.vim.org/scripts/script.php?script_id=2307. I thank that author for the inspiration.

For more information, type :help latexfmt.

vim-latexfmt's People

Contributors

engeljh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.