简体   繁体   中英

Vim - Get a list of all mappings set in a specific file

I was looking at my vimrc recently, and I was wondering which mappings I really use. So, I thought that a "mapcop" type plugin would be very useful, but that would require getting a list of all mappings defined in a certain file. I know that you can get where a mapping was defined by doing :verbose {map_type}map {mapping} , but that won't really cut it for what I want to use it for.

these commands could show {map_type}map {mapping} created in certain file:

:redir @x
:verbose map
:redir END
:%d|pu x
:g/filename$/-1 y M
:%d|pu m
  • the filename you have to do escaping, like \\~\\/[.]vimrc$ for ~/.vimrc
  • after executing this sequence, the mappings created in filename will be put in current buffer (the original text in buffer will be cleared)
  • you can wrap those commands in function to make it easy to be called.
  • note that the mappings in certain file are just last time defined in that file, same as your verbose map output

使用标签栏插件,您可以查看vimscript文件中定义的所有映射,包括.vimrc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM