On Jun 30, 4:56 pm, Ben Fritz <[email protected]> wrote: > On Jun 29, 10:51 am, Edward Beach <[email protected]> wrote: > > > I can convert the normal mappings into commands, > > i.e. com! -bar -nargs=0 MoveLineDownInNormalMode normal mz:m+<CR>'z== > > but how can I convert insert and visual mappings into similar command > > formats? > > What exactly are you trying to do? Can you actually envision a use- > case for this? > > To enter an Ex command while in insert mode, you need to leave insert > mode (possibly temporarily). There isn't really a way to create an Ex > command to execute from insert mode. > > Pressing ':' in visual mode also ends visual mode. The only difference > between : in visual mode and : in normal mode is that the visual > selection is automatically inserted as the range for your command on > the command line. Therefore there isn't really a special way to create > a "visual mode" Ex command either.
The goal was to replace complicated keystrokes with commands so that I could simplify my mappings (i.e keyboard, menu, etc). The above was just an example I pulled from the wiki hoping that people would be familiar with it but regardless I think I've figured out a way to do it by adding the range option to the command syntax and specifying the range in the ex line: com! -bar -range -nargs=0 MoveLinesDownInVisualMode normal :'<,'>m'> +<CR>gv=`<my`>mzgv`yo`z --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
