How do I edit an existing mapping in vim? I set the mapping in my .vim file using one of the standard mapping commands:
map ^A o]]></code>^M<GRD minus="" summary="">^M^M<p></p>^M^M</GRD>^M^M<code><![CDATA[0kkkkkk5ehi
I want to edit this long command to use "matlab" instead of code, e.g.:
map ^A o]]></matlab>^M<GRD minus="" summary="">^M^M<p></p>^M^M</GRD>^M^M<matlab><![CDATA[0kkkkkk5ehi
However, I don't want to edit the .vim file -- I will use the original mapping again. I just want to change the mapping for my current session. I tried :map ^A, but this only displays the current mapping, and I cannot copy the displayed text.
P.S. Note that the ^M and ^A characters are inserted with Ctrl-Q Ctrl-M, etc.
Tweaking a mapping for a current session only is unusual; probably that's why it's supported poorly. I would guess that you're not actually concerned about a session, but rather a Matlab filetype. For that, there's excellent support. If the
'filetype'
is detected asmatlab
, you can put a buffer-local mapping variant in~/.vim/after/ftplugin/matlab.vim
:Direct editing
If you'd rather stick with your original plan, I would do it like that:
:split ~/.vimrc
yy
:@"
:bdelete!
Alternative
For a more general solution, you could also capture the output of the original
:map ^A
command via:redir
, then:put
that into a:new
scratch buffer, and finally:source
that. It's more manual steps and typing, but could be automated by a custom command. Worthwhile if you need this often.