Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving output of :map in vim

Tags:

vim

Q1: Is there a way of saving the output of the command

:map

to a file?

Q2: In a related question, I have the following map in my vimrc file:

map <f1> :wa<cr>

When I load a latex file (I have the vim-latex plugin installed), the F1 key now invokes help.
Is there a way of changing this without manually having to type the map again?

like image 394
skeept Avatar asked Feb 10 '10 18:02

skeept


2 Answers

A1: To redirect/save the output of :map:

:redir >> ~/mymaps.txt
:map
:redir END

A2:

As kemp says, you can find it using verbose and modify the plugin file.

Or you can create a vim file in your plugins directory that runs last, e.g., ~/.vim/plugin/zzzmyremaps.vim (check by running scriptnames)

Edit: rampion is correct in the comments. Because this is a filetype issue, this should be handled in the after directory ~/.vim/after/plugin/latex.vim as the offending latex.vim file is not being loaded on startup but on a buffer enter.

Note .vimrc gets sourced first so plugins have a habit of overwriting them. :scriptnames will show the order.

like image 175
michael Avatar answered Oct 06 '22 19:10

michael


If your problem is that <F1> gets remapped, you can use :verbose map <F1> to see where it is defined, and change it accordingly.

like image 21
Matteo Riva Avatar answered Oct 06 '22 18:10

Matteo Riva