On Sat, Oct 21, 2017 at 4:25 AM, Ben Fritz <fritzophre...@gmail.com> wrote: > On Friday, October 20, 2017 at 5:29:53 PM UTC-5, Jose Caballero wrote: >> Hi, >> >> I would only need to know which key words I need to search in google... :) >> I have a few remaps (and iremaps) that modify the current line. For >> example, to add # at the beginning, and stuff like that. >> I would like to know how to re-use those mappings for a block of >> lines, not line by line. >> I am wondering if there is a way, for example, to apply it to a >> visually select block, or similar. >> >> Any clue, or link, where I can educate myself on this topic, would be >> appreciated. >> As I said, at this point, I don't even know which key to search with :help >> >> Thanks a lot in advance. >> Jose > > Easy way (no extra effort): visually select the lines you want, and type > ":normal " and then your mapping. You should see ":'<,'>normal ". Press enter > to run the command on every line. > > Harder way would be to create a visual mode mapping that somehow invokes the > behavior you want on each line. Then for bonus points consider an > operator-pending mapping.
Yeah, and for extra bonus points: construct a function with a "range" qualifier (see :help :function and :help E124) and/or a user-command with a -range attribute, probably defaulting to current line (see :help :command and :help :command-range) and update your mapping to invoke them. If you define both in a single script (e.g. in your vimrc or in an ftplugin), it is possible to define a public (i.e. user-facing) command which calls a private (i.e. script-local) function. Best regards, Tony. -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.