* Benji Fisher on Thursday, July 27, 2006 at 13:13:39 -0400:
> On Thu, Jul 27, 2006 at 09:34:59AM +0200, Christian Ebert wrote:
>> * Benji Fisher on Wednesday, July 26, 2006 at 22:58:07 -0400:
>>> :vmap <C-S> :<C-U> PySort()<CR>
>>
>> For the above: Would
>>
>> :vmap <C-S> <Esc>:PySort()<CR>
>>
>> do the same thing?
>>
>> If no, what is the difference?
>> If yes, what is the "canonical" way to do it?
>
> Since we are both using :vmap and not :vnoremap, we are both
> vulnerable to unexpected results from user-defined mappings.
Yes, I actually use :vnoremap, but concentrated on <C-U> vs.
<Esc>.
> If the user has 'insertmode' set, then <Esc> will go to Insert mode
> rather than Normal mode, You can use <C-\><C-N> to be safe.
Ah, didn't think of that ... but :help 'insertmode' says:
However, when <Esc> is used inside a mapping, it behaves like
'insertmode' was not set. This was done to be able to use the same
mappings with 'insertmode' set or not set.
Interesting though, :help c_Ctrl-\ takes me to c_Ctrl-\_e ...
> Your version can be abbreviated, if you keep your :map , to
>
> :vmap <script> <C-S> <C-\><C-N><C-S>
Hm. Now I have to try to understand what exactly <C-\><C-N> does
...
> Check the docs before relying on this, but IIRC :vmap and :vnoremap
> behave the same if you add <script> .
Indeed.
:help :map-<script>
Note: ":map <script>" and ":noremap <script>" do the same thing. The
"<script>" overrules the command name. Using ":noremap <script>" is
preferred, because it's clearer that remapping is (mostly) disabled.
The mapping I had in mind goes in fact like so:
:vnoremap <script> <Plug>MyscriptDo <Esc>:call MyscriptDo()<CR>
I just wanted to know, whether :<C-U>call MyscriptDo()<CR> as
{rhs} is preferred, faster, or has other advantages.
> Other than these minor differences, my original suggestion and
> yours should do exactly the same things.
Ok. Thanks.
c
--
_B A U S T E L L E N_ lesen! --->> <http://www.blacktrash.org/baustellen.html>