Simple latex ctags and taglist

Just a quick update because I find this incredibly useful

ctags

Exuberant ctags is a great tool for navigating code. Unfortunately it does not have support for latex. You can add the following code to ~/.ctags to add support for some simple latex tags:

--langdef=latex
--langmap=latex:.tex
--regex-latex=/\\label\{([^}]*)\}/\1/l,label/
--regex-latex=/\\section\{([^}]*)\}/\1/s,section/
--regex-latex=/\\subsection\{([^}]*)\}/\1/t,subsection/
--regex-latex=/\\subsubsection\{([^}]*)\}/\1/u,subsubsection/
--regex-latex=/\\section\*\{([^}]*)\}/\1/s,section/
--regex-latex=/\\subsection\*\{([^}]*)\}/\1/t,subsection/
--regex-latex=/\\subsubsection\*\{([^}]*)\}/\1/u,subsubsection/

This adds tags for sections, subsections, subsubsections and labels. Even though this is very basic, I find it’s all I need for editing latex documents.

taglist

taglist is a nice plugin for vim which autogenerates tags using exuberant-ctags and can list all the tags in a file in a separate window.

You can add latex support to it by adding this line in your ~/.vimrc (assuming you have already added the code given above to .ctags)

let tlist_tex_settings = 'latex;l:labels;s:sections;t:subsections;u:subsubsections'

Also, since I use the ‘-’ and ‘:’ characters a lot in my labels, I find it useful to add those characters to iskeyword

set iskeyword=@,48-57,_,-,:,192-255

iskeyword defines what characters are considered to be a part of the same word by commands like ‘w’ and ‘CTRL-]’

That’s it!

About these ads

~ by hellfeuer on November 16, 2009.

3 Responses to “Simple latex ctags and taglist”

  1. Thanks . Very usefull to navigate latex file with vim :D

  2. works.. thx!

  3. Thanks !

    You can add “^\s*” before =/ to avoid listing commented sections, and allow spaces before \section. Example :

    “–regex-latex=/^\s*\\section\{([^}]*)\}/\1/s,section/”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: