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:
> > On Tue, Jul 25, 2006 at 12:36:44AM +0400, Pavel Volkovitskiy wrote:
> >> map <C-S> :call PySort()<CR>
> > 
> > How about calling it directly from Visual mode?
> > 
> > :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?
> 
> TIA

     Since we are both using :vmap and not :vnoremap, we are both
vulnerable to unexpected results from user-defined mappings.

     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.

     Your version can be abbreviated, if you keep your :map , to

:vmap <script> <C-S> <C-\><C-N><C-S>

Check the docs before relying on this, but IIRC :vmap and :vnoremap
behave the same if you add <script> .

     Other than these minor differences, my original suggestion and
yours should do exactly the same things.

HTH                                     --Benji Fisher

Reply via email to