Saturday, 9 August 2014

[Vim] open VOom outliner automatically for specific file type

VOom (Vim Outliner of Markups) is a very useful outline plugin for Vim. It can support many markup modes, such as popular markdown, latex, pandoc, html and python. For me,
  • markdown - used to write notes, and it can be easily converted into html or pdf by markdown2.py, pandoc or Mou, then paste html to blog
  • latex - used to write research paper

Typical Usage of VOom

  • Use Vim to open Latex file
  • Type :Voom latex to open VOom outline window in left panel
  • Use the section tree in VOom for jumping to desired section of paper

The Problems

However sometimes I have to open up to ten Latex files for editing at the same time, I need typing :Voom latex for ten times. It's not productive and boring.

Solution

Vim has an autocmd feature to open a command automatically depending on the events. More detials see vimdoc (:help autocmd).
  • Add the following lines in .vimrc

    " after read in tex file and then execute Voom latex 
    autocmd BufRead *.tex :Voom latex 
    autocmd BufRead *.mkd :Voom markdown
    
  • It will execute :Voom latex when opening a Latex file and :Voom markdown for mkd file

No comments :

Post a Comment