Is it possible to include multiple file types when using the `FileType` event?

Absolutely:

au FileType tex,latex,context,plaintex nm <C-H> <Plug>IMAP_JumpForward

Some thoughts:

  • Should be using a buffer local mapping instead of a global mapping
  • Using short names has only cons and zero pros. Don’t.
  • This autocmd should be in a group
  • Autocmd’s should be cleared (inside a group) so that re-sourcing is not a problem
  • Maybe use a after ftplugin script. e.g. ~/.vim/after/ftplugin/tex.vim instead of an :autocmd as they are easier to manage
  • look into romainl’s idiomatic vimrc for more vimrc do’s/don’t’s

Cleaned up version:

augroup tex_mappings
    autocmd!
    autocmd FileType tex,latex,context,plaintex nmap <buffer> <c-h> <Plug>IMAP_JumpForward
augroup END

Alternatively add the following to ~/.vim/after/ftplugin/txt.vim:

nmap <buffer> <c-h> <Plug>IMAP_JumpForward

Note: with the ftplugin approach you will need to add this line for each FileType (or use :source)

For more help see:

:h :au
:h :aug
:h :map-local
:h after-directory

Leave a Comment