Wednesday, May 7, 2014

Re: When is map useful (as apposed to noremap)

James Wood wrote:
> If I understand correctly, map commands (nmap, imap...) allow the
> resulting action to be affected by any other key bindings that happen to
> have been made. On the other hand, their noremap counterparts act as if
> no other mappings have been made. I can't think of any situations where
> one would want the result to be affected by other bindings, since this
> would be very hard to maintain. Are plain maps used much? Why?

Plain maps are all you get in real vi, so people coming from that
background will use them by default. Some other reasons:

Making complex maps that can be tested piece by piece and then chained
together.

Making subroutine maps that can be called by other maps.

Making maps that are recursive.

Look at the toy macro sets that come with vim. Towers of Hanoi, eg:

" to set the height of the tower, change the digit in the following
" two lines to the height you want (select from 1 to 9)
map t 7
map! t 7

That's using a map as a variable. Then later in the macro set it gets used
like this:

"delete more than height-of-tower characters
map q tllD

Elijah

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: