Tuesday, June 18, 2013

Re: vim conditional keymap when a tex file is open

vim file.tex
:echo &filetype

then edit:
~/.vim/ftplugin/{the result of the echo command}.vim

{the result of the echo command} may be "tex" or "latex" depending on
which plugins you have installed.

add something like this there to that file:

noremap <buffer> <leader>lw :do thing

<buffer> means the mapping will only active in the current buffer.

Notes: filereadable does not accept glob patterns, use :h glob() first.
To detect current extension use expand('%:e')

Eventually you want to learn about quickfix, too. Simple example usage:

exec 'set makeprg=mktex' | make %

this runs mktex on the current file, then loads the error into the
quickfix cycle.

:h compiler
:h errorformat

may be useful, too.

Because error formats from latex are hard to read by vim there are
additional "translators" which run latex for you and print nice error
locations instead. If you need more help about this use case write
again.

Marc Weber

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment