On 13/01/09 07:28, John Beckett wrote:
> Sitaram Chamarty wrote:
>>> :cnoremap<expr> <CR> ((getcmdtype == '/'<Bar><Bar>
>>> getcmdtype == '?')?"<Bslash>CR>:set fdm=expr":'')
>> Can someone explain this a bit more slowly for me please?
>
> The 'getcmdtype' should be 'getcmdtype()'. I can't offer more help at
[...]
Yes, getcmdtype should be getcmdtype(), and "<Bslash>CR> should be
"<Bslash>r
":cnoremap" means a no-remapped mapping for command-line mode. <expr>
means that the map-to text is obtained by evaluating an expression.
<buffer> means the mapping will only be used in the buffer which was
current at the time it was defined. By rereading the above, I notice a
few more errors. So let me rewrite it (all on one line):
:cnoremap <expr> <CR> ((getcmdtype() == '/' <Bar><Bar> getcmdtype() ==
'?')? "<Bslash>r:set fdm=expr<Bslash>r" : "<Bslash>r")
Now here are the explanations:
<Bslash> in a mapping is replaced by \ in the result, and <Bar> by |
So the expression to exaluate is (still all on one line)
((getcmdtype() == '/' || getcmdtype() == '?')? "\r:set fdm=expr\r" : "\r")
IOW, if getcmdtype() is a slash or a question mark, the Enter key maps
to "\r:set fdm=expr\r" and since this is a double-quoted string, \r in
it means a carriage-return (the Enter key). Otherwise, the Enter key
maps to itself.
See
:help map-overview
:help :noremap
:help :map-<buffer>
:help :map-<expr>
:help keycodes
:help <Bslash>
:help <Bar>
:help expr1
:help getcmdtype()
Best regards,
Tony.
--
5 out of 4 people have trouble with fractions.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---