Monday, July 26, 2010

Re: Writing :map and :map! to text file or something

Just what I need. Thank you!

Gary Furash | 520-907-2470 | furashgary@gmail.com


On Mon, Jul 26, 2010 at 10:36 AM, Tony Mechelynck <antoine.mechelynck@gmail.com> wrote:
On 26/07/10 18:42, Gary wrote:
How would you get the output of :map and :map! to save to a file?


see :help :redir

For a list which wouldn't need to be fed back as input to Vim,

       :let save_more = &more
       :set nomore
       :redir! > ~/mappings.txt
       :0verbose map
       :0verbose map!
       :redir END
       :let &more = save_more

would be enough. If you _do_ need to feed it back, then you would need a number of substitutes. The points to be taken care of are:
       - removing the xxx on each line
       - beware of special characters (space, quote, bar, bslash, etc.)
       - Console Vim may list termcap codes rather than <> codes
       - linked groups are to be treated differently than the rest
       - coded symbols for
               nmap, vmap, imap etc.
               (nore)map
               <expr>
               <buffer>
                       etc., see :help :map-arguments
         are to be translated. See also :help map-listing
       - the possibility of <buffer> mappings may require repeating the :map and :map! commands for each buffer, but the script to be sourced will have to know how to set the <buffer> mappings in the buffer they are meant for...
       - and maybe others which don't cross my mind at the moment

The actual code to use in this case is left as an exercise to the student.


...oh, and maybe you can take advantage of the :mksession command,
see
       :help :mksession
       :help 'sessionoptions'


Best regards,
Tony.
--
As I was going up Punch Card Hill,
       Feeling worse and worser,
There I met a C.R.T.
       And it drop't me a cursor.

C.R.T., C.R.T.,
       Phosphors light on you!
If I had fifty hours a day
       I'd spend them all at you.

               -- Uncle Colonel's Cursory Rhymes

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: