On 09/01/09 18:22, Tim Chase wrote:
>> Absolutely amazing! I think of doing something that would
>> make it much easier to do a particular task in Vim but have no
>> idea how to do it, post a note to the list and with minutes
>> someone comes up with a solution! I'm flabbergasted!
>> Brilliant!
>
> And I felt bad that it required a *manual* fold-refresh...
>
> There have been times I've wished for a "post-search" autocmd --
> even stooping to some obscenely fragile hacks (mappings that
> create and delete other mappings) to get such a beast to work.
> In my hypothetical world, one might be able to do this more
> cleanly as
>
> :autocmd SearchPost * :set foldmethod=expr...
>
> Alas, there's no such SearchPost event. :(
>
> There's also not a distinction for command-line mappings to
> discern a "search" command-line from a "colon" command-line, so I
> can't use a mapping to do something like (assuming "scnoremap"
> was a search-command-line
>
> :scnoremap<cr> <cr>:set foldmethod...<cr>
>
> Either would be helpful in such a situation, but alas...no such
> joy in Vim.
>
> Perhaps this thread may spark a weekend hack by one of the
> vim-developers. :)
>
> -tim
Oh, but you can set up mappings for search commands as distinct from
mappings for ex-commands. Here's an example:
:cnoremap <expr> <CR> ((getcmdtype == '/' <Bar><Bar> getcmdtype ==
'?')?"<Bslash>CR>:set fdm=expr":'')
The above requires Vim 7.0 or later, and of course with expression
evaluation compiled-in.
Best regards,
Tony.
--
Iles's Law:
There is always an easier way to do it. When looking directly
at the easy way, especially for long periods, you will not see it.
Neither will Iles.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---