Manfred Georg wrote:
Hi,

Apparently this isn't a very popular thing to do, but I remap g
to help me do indentation.  There are two problems with this.
In gvimrc_example.vim , there is some code (which has been copied
all sorts of places) which does automatic
jump to last position when file was closed.  This uses the command g'"
Unfortunately when g has been remapped it triggers this mapping.

To fix this the line with \| exe "normal g'\"" | endif
should read
\| exe "normal! g'\"" | endif

the ! stops it from remapping g to the local mapping.

Also, some plugins create some mappings that start with g .
The problem is that I don't want to wait for the disambiguation delay
before triggering my mapping.  So I want to unmap those mappings in
the user .vimrc .  The problem is that plugins are sourced after
the user .vimrc .  This makes it impossible to countermand the
mappings created by the plugins automatically (barring using even more
magical techniques like autocmd).  It really seems to me like the
.vimrc should be sourced after the plugins, it should have the final say.

Thank you,

Manfred

Method I (secommended)
--------
Map something which will not collide with Vim's own mappings, such as F7 (which is still reachable by extending the fingers straight up from the home position).

Method II
---------
There are still settings which should be set before everything happens (such as 'nocompatible' or ":language") and that's reason enough to keep the vimrc before all the rest. But you can still create a script to be sourced after all plugins: write an after-plugin (see ":help after-directory) and name your script, for instance (on Unix/Linux) ~/.vim/after/plugin/zzzzlast.vim or (in Vim notation on Windows) ~/vimfiles/after/plugin/zzzzlast.vim (the name starting with zzzz is intended to have it sourced even after your own other after-plugins if any). Place into this file any commands that must imperatively be run after all plugins.

Method III
----------
If Method II doesn't source your custom script late enough, place it in some other directory, for example (depending on platform) ~/.vim/macros/ or ~/vimfiles/macros/ and source it from an autocommand for the VimEnter event, i.e.,

        :autocmd VimEnter * runtime macros/zzzzlast.vim

This autocommand would be defined (one line) in your vimrc.


Best regards,
Tony.

Reply via email to