Since i$
is a mapping itself (defined by the vimtex plug-in), you need a recursive mapping to be able to use i$
as part of the expansion of your mapping.
So this should work:
nmap cim ci$
But you can also create an operator-pending mode mapping for im
, in which case that would work with other operations such as dim
or yim
and other built-in or custom operations that take a motion:
omap im i$
If vimtex also defines i$
in Visual mode (which is a common pattern), you might want to create the mapping for your alias in Visual mode as well:
xmap im i$
Finally, you may want to define these mappings only for tex
files, so consider adding these commands to ~/.vim/after/ftplugin/tex.vim
(so it's loaded only for files with FileType tex
, and only after the vimtex plug-in has been loaded.)
Finally, you want to use <buffer>
to make your mappings local to your buffer, so they're loaded for buffers of that filetype and do not leak into other filetypes:
omap <buffer> im i$
xmap <buffer> im i$
Finally, you might want to modify the b:undo_ftplugin
variable to remove these mappings if the filetype-related plug-in actions need to be undone. See :help undo_ftplugin
for more details on that.
If you simply want im
as an alias to i$
in all cases (assuming other plug-ins might have their own definition for i$
), then global mappings for it might be acceptable, they certainly work.