I would like to use latexindent from the vi editor. Ideally, I would use it just like one uses fmt. Recall that in vi you can filter any portion of your text through an external filter. So, one could type !}fmt and upon hitting return, the current paragraph is formatted as if it was text. Similarly, you can type !}sort -u to sort a list, removing any duplicates, etc.

Ideally, one could write !}latexindet -someflags to LaTeX format the current paragraph.

Benefits of this workflow are being able to quickly undo the changes by simply hitting u, and the ability to apply indentation at a finer grain.

I will wait a little, before posting my answer to this problem.

  • 2
    I have nmap <Tab> == and vmap <Tab> == in my .vimrc. With these definitions I can indent the current line according to its surroundings by pressing "Tab" in command mode. In visual mode I can also select some lines and press "Tab". (maybe needs set autoindent) – Henri Menke Jan 6 '14 at 10:58
  • 1
    I use arara youtubde demonstration – cmhughes Jan 7 '14 at 23:09

Create a bash script named, say, ind whose content is:

#!/bin/sh -f
cat > /tmp/$$ 
latexindent -l /tmp/$$

make it executable, and add it to your path. Then type !}ind.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.