3

I have vim-latex installed via Vundle and I'm trying to disable some annoying mapping that it sets up by default. From the docs I know that, for example, I can use the following command to unmap FEM:

call IUNMAP('FEM','tex')

But when I type that I get the error E117: Unknown function: IUNMAP.

I have installed vim-latex with Vundle by including Plugin 'LaTeX-Suite-aka-Vim-LaTeX' in my vimrc and I have just used the PluginUpdate command to update everything, which runs with no error, so I should have the latest version of the package.

Am I missing something here?

TomCho
  • 3,204
  • 6
  • 32
  • 83
  • 1
    Yes, you are missing [VimTeX](https://github.com/lervag/vimtex). Please, give a look at [this](https://vi.stackexchange.com/q/2047/6498). – Enlico Feb 22 '20 at 20:31
  • @EnricoMariaDeAngelis Useful link. However, I installed `vimtex` via Vundle and still got the same result when trying the `IUNMAP` command – TomCho Feb 22 '20 at 23:37
  • my comment is a comment, not meant to be a solution. However, based on your link, it seems `IUNMAP` is a Vim-LaTeX thing. So if you switch to VimTeX, you don't have to worry about its mappings. Uninstall Vim-LaTeX and just forget about it. – Enlico Feb 22 '20 at 23:54
  • Consider using `Plug 'vim-latex/vim-latex'` to get vim-latex from [here](https://github.com/vim-latex/vim-latex), which looks like a more official authoritative source for it... – filbranden Feb 23 '20 at 01:34

2 Answers2

2

Actually, the problem you're having is related to where you're getting your vim-latex from.

With:

Plug 'LaTeX-Suite-aka-Vim-LaTeX'

You're getting it from here, which you'll notice hasn't been updated since 2010. Looking at the plugin/imaps.vim file in that repository, you'll see there's a definition for function IMAP(), but not for IUNMAP(), which was probably introduced after the last date that repository was synced...

Use this source instead:

Plug 'vim-latex/vim-latex'

Which will get it from here which is an official maintained location for this plug-in.

If you look at plugin/imaps.vim in that source tree, you'll notice function! IUNMAP is defined there.

Updating to the correct plug-in location should fix this problem for you (together with probably quite a few fixes from the last 10 years!)

filbranden
  • 8,522
  • 2
  • 16
  • 32
  • 1
    Ugh, I can't believe I missed that.... In my defense the names don't exactly make this easy to spot – TomCho Feb 23 '20 at 07:57
1

The functions IMAP() and IUNMAP() are loaded by the vim-latex plug-in only after your vimrc is processed. So you need to execute them from a context where they're available.

Furthermore, in order to have your unmapping succeed, you need to actually execute it after the mapping was created, and mappings are typically created when the filetype is set.

The documentation mentions that these overriding rules should be done in specific files:

An important thing to note is that if you wish to over-ride macros created by Latex-Suite rather than merely create new macros, you should place the IMAP() (or IUNMAP()) calls in a script which gets sourced after the files in Latex-Suite.

A good place typically is as a file-type plugin file in the ~/.vim/after/ftplugin/ directory. [...]

For example, to delete a mapping, you can use

call IUNMAP('FEM', 'tex')

in ~/.vim/after/ftplugin/tex_macros.vim.

The documentation mentions that you should use a file in ftplugin after the filetype you use. Check :set ft? to confirm yours is indeed tex, in which case you can use tex.vim, tex_something.vim (like the suggested tex_macros.vim) or tex/something.vim (a subdirectory.)

filbranden
  • 8,522
  • 2
  • 16
  • 32